mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 11:58:55 +00:00
landing the AB_OUTLINER_BRANCH.
fix for #73868, and numerous other bugs. switch the addressbook over to use outliner, a bunch of addressbook UI fixes and code cleanup. r=dmose,racham,others and sr=bienvenu
This commit is contained in:
parent
2ba5b3fc8e
commit
d08d4d3f97
@ -1389,7 +1389,7 @@ nsAbSync::AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *director
|
||||
mNewSyncMapingTable = (syncMappingRecord *) PR_MALLOC(mNewTableSize * sizeof(syncMappingRecord));
|
||||
if (!mNewSyncMapingTable)
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;;
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto GetOut;
|
||||
}
|
||||
|
||||
@ -2237,7 +2237,7 @@ nsAbSync::ProcessServerResponse(const char *aProtocolResponse)
|
||||
sizeof(syncMappingRecord), &writeSize))
|
||||
|| (writeSize != sizeof(syncMappingRecord)))
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;;
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto ExitEarly;
|
||||
}
|
||||
}
|
||||
@ -2260,7 +2260,7 @@ nsAbSync::ProcessServerResponse(const char *aProtocolResponse)
|
||||
sizeof(syncMappingRecord), &writeSize))
|
||||
|| (writeSize != sizeof(syncMappingRecord)))
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;;
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto ExitEarly;
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,9 @@ REQUIRES = xpcom \
|
||||
necko \
|
||||
msgcompose \
|
||||
mime \
|
||||
msgbase \
|
||||
rdf \
|
||||
msgbase \
|
||||
msgbaseutil \
|
||||
rdfutil \
|
||||
docshell \
|
||||
appshell \
|
||||
@ -47,6 +48,8 @@ REQUIRES = xpcom \
|
||||
locale \
|
||||
mork \
|
||||
appcomps \
|
||||
layout \
|
||||
intl \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = nsAbFactory.cpp
|
||||
@ -61,9 +64,17 @@ SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)addrbook_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LIBS = rdfutil_s
|
||||
|
||||
ifeq ($(USE_SHORT_LIBNAME),1)
|
||||
EXTRA_DSO_LIBS += msgbsutl
|
||||
else
|
||||
EXTRA_DSO_LIBS += msgbaseutil
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(LIBS_DIR) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)rdfutil_s.$(LIB_SUFFIX) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
@ -31,6 +31,7 @@ REQUIRES = xpcom \
|
||||
msgcompo \
|
||||
mime \
|
||||
msgbase \
|
||||
msgbaseutil \
|
||||
rdf \
|
||||
rdfutil \
|
||||
docshell \
|
||||
@ -41,6 +42,8 @@ REQUIRES = xpcom \
|
||||
mork \
|
||||
appcomps \
|
||||
mozldap \
|
||||
layout_xul \
|
||||
intl \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
@ -67,6 +70,7 @@ SUB_LIBRARIES=\
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\msgbsutl.lib \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\rdfutil_s.lib \
|
||||
$(DIST)\lib\unicharutil_s.lib \
|
||||
|
@ -72,19 +72,6 @@
|
||||
{0xa2, 0xda, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
|
||||
}
|
||||
|
||||
//
|
||||
// nsAbCardDataSource
|
||||
//
|
||||
#define NS_ABCARDDATASOURCE_CONTRACTID \
|
||||
NS_RDF_DATASOURCE_CONTRACTID_PREFIX "addresscard"
|
||||
|
||||
#define NS_ABCARDDATASOURCE_CID \
|
||||
{ /* 1920E486-0709-11d3-A2EC-001083003D0C */ \
|
||||
0x1920e486, 0x709, 0x11d3, \
|
||||
{0xa2, 0xec, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsAbBSDirectory
|
||||
//
|
||||
@ -114,7 +101,7 @@
|
||||
// nsAbMDBCard
|
||||
//
|
||||
#define NS_ABMDBCARD_CONTRACTID \
|
||||
NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX "moz-abmdbcard"
|
||||
"@mozilla.org/addressbook/moz-abmdbcard;1"
|
||||
|
||||
#define NS_ABMDBCARD_CID \
|
||||
{ /* {f578a5d2-1dd1-11b2-8841-f45cc5e765f8} */ \
|
||||
@ -204,7 +191,8 @@
|
||||
// addbook URL
|
||||
//
|
||||
#define NS_ADDBOOKURL_CONTRACTID \
|
||||
"@mozilla.org/addressbook/services/addbookurl;1"
|
||||
"@mozilla.org/addressbook/services/url;1?type=addbook"
|
||||
|
||||
#define NS_ADDBOOKURL_CID \
|
||||
{ /* ff04c8e6-501e-11d3-a527-0060b0fc0444 */ \
|
||||
0xff04c8e6, 0x501e, 0x11d3, \
|
||||
@ -263,7 +251,7 @@
|
||||
// nsAbOutlookCard
|
||||
//
|
||||
#define NS_ABOUTLOOKCARD_CONTRACTID \
|
||||
NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX "moz-aboutlookcard"
|
||||
"@mozilla.org/addressbook/moz-aboutlookcard"
|
||||
|
||||
#define NS_ABOUTLOOKCARD_CID \
|
||||
{ /* {32cf9734-4ee8-4f5d-acfc-71b75eee1819}*/ \
|
||||
@ -341,7 +329,7 @@
|
||||
// nsAbLDAPCard
|
||||
//
|
||||
#define NS_ABLDAPCARD_CONTRACTID \
|
||||
NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX "moz-abldapcard"
|
||||
"@mozilla.org/addressbook/moz-abldapcard"
|
||||
|
||||
#define NS_ABLDAPCARD_CID \
|
||||
{ /* {10307B01-EBD6-465F-B972-1630410F70E6}*/ \
|
||||
@ -372,4 +360,13 @@
|
||||
#define NS_ABLDAPAUTOCOMPFORMATTER_CONTRACTID \
|
||||
"@mozilla.org/ldap-autocomplete-formatter;1?type=addrbook"
|
||||
|
||||
// nsABView
|
||||
|
||||
#define NS_ABVIEW_CID \
|
||||
{ 0xc5eb5d6a, 0x1dd1, 0x11b2, \
|
||||
{ 0xa0, 0x25, 0x94, 0xd1, 0x18, 0x1f, 0xc5, 0x9c }}
|
||||
|
||||
#define NS_ABVIEW_CONTRACTID \
|
||||
"@mozilla.org/addressbook/abview;1"
|
||||
|
||||
#endif // nsAbBaseCID_h__
|
||||
|
@ -48,19 +48,12 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
/* Include all of the interfaces our factory can generate components for */
|
||||
|
||||
#include "nsDirectoryDataSource.h"
|
||||
#include "nsCardDataSource.h"
|
||||
|
||||
#include "nsAbBSDirectory.h"
|
||||
|
||||
#include "nsAbMDBDirectory.h"
|
||||
#include "nsAbMDBCard.h"
|
||||
|
||||
#include "nsAbDirFactoryService.h"
|
||||
#include "nsAbMDBDirFactory.h"
|
||||
|
||||
#include "nsAddrDatabase.h"
|
||||
#include "nsAddressBook.h"
|
||||
#include "nsAddrBookSession.h"
|
||||
@ -79,6 +72,7 @@
|
||||
#include "nsAbDirectoryQuery.h"
|
||||
#include "nsAbBooleanExpression.h"
|
||||
#include "nsAbDirectoryQueryProxy.h"
|
||||
#include "nsAbView.h"
|
||||
|
||||
#if defined(MOZ_LDAP_XPCOM)
|
||||
#include "nsAbLDAPDirectory.h"
|
||||
@ -88,26 +82,20 @@
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddressBook)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbDirectoryDataSource,Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbCardDataSource,Init)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirProperty)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbCardProperty)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBSDirectory)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBDirectory)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBCard)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddrDatabase)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddrBookSession)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbAutoCompleteSession)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbAddressCollecter)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbAddressCollecter,Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddbookUrl)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirFactoryService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBDirFactory)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddbookProtocolHandler)
|
||||
|
||||
#ifdef XP_WIN
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOutlookDirectory)
|
||||
@ -127,8 +115,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPAutoCompFormatter)
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryProxy)
|
||||
|
||||
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddbookProtocolHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbView);
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
@ -149,20 +136,11 @@ static nsModuleComponentInfo components[] =
|
||||
NS_ABDIRECTORYDATASOURCE_CONTRACTID,
|
||||
nsAbDirectoryDataSourceConstructor },
|
||||
|
||||
{ "Address Book Card Datasource",
|
||||
NS_ABCARDDATASOURCE_CID,
|
||||
NS_ABCARDDATASOURCE_CONTRACTID,
|
||||
nsAbCardDataSourceConstructor },
|
||||
|
||||
|
||||
|
||||
{ "Address Boot Strap Directory",
|
||||
NS_ABDIRECTORY_CID,
|
||||
NS_ABDIRECTORY_CONTRACTID,
|
||||
nsAbBSDirectoryConstructor },
|
||||
|
||||
|
||||
|
||||
{ "Address MDB Book Directory",
|
||||
NS_ABMDBDIRECTORY_CID,
|
||||
NS_ABMDBDIRECTORY_CONTRACTID,
|
||||
@ -173,7 +151,6 @@ static nsModuleComponentInfo components[] =
|
||||
NS_ABMDBCARD_CONTRACTID,
|
||||
nsAbMDBCardConstructor },
|
||||
|
||||
|
||||
{ "Address Database",
|
||||
NS_ADDRDATABASE_CID,
|
||||
NS_ADDRDATABASE_CONTRACTID,
|
||||
@ -208,7 +185,7 @@ static nsModuleComponentInfo components[] =
|
||||
{ "The addbook Protocol Handler",
|
||||
NS_ADDBOOK_HANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "addbook",
|
||||
nsAddbookProtocolHandler::Create },
|
||||
nsAddbookProtocolHandlerConstructor },
|
||||
|
||||
{ "The directory factory service interface",
|
||||
NS_ABDIRFACTORYSERVICE_CID,
|
||||
@ -278,7 +255,13 @@ static nsModuleComponentInfo components[] =
|
||||
{ "The directory query proxy interface",
|
||||
NS_ABDIRECTORYQUERYPROXY_CID,
|
||||
NS_ABDIRECTORYQUERYPROXY_CONTRACTID,
|
||||
nsAbDirectoryQueryProxyConstructor }
|
||||
nsAbDirectoryQueryProxyConstructor },
|
||||
|
||||
{ "addressbook view",
|
||||
NS_ABVIEW_CID,
|
||||
NS_ABVIEW_CONTRACTID,
|
||||
nsAbViewConstructor }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -115,6 +115,16 @@
|
||||
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
|
||||
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
|
||||
</SETTING>
|
||||
<SETTING>
|
||||
<SETTING><NAME>SearchPath</NAME>
|
||||
<SETTING><NAME>Path</NAME><VALUE>:::base:util:macbuild:</VALUE></SETTING>
|
||||
<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
|
||||
<SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
|
||||
</SETTING>
|
||||
<SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
|
||||
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
|
||||
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
|
||||
</SETTING>
|
||||
</SETTING>
|
||||
<SETTING><NAME>SystemSearchPaths</NAME>
|
||||
<SETTING>
|
||||
@ -982,13 +992,6 @@
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCardDataSource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsDirectoryDataSource.cpp</PATH>
|
||||
@ -1122,13 +1125,6 @@
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbMDBRDFResource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbBoolExprToLDAPFilter.cpp</PATH>
|
||||
@ -1248,6 +1244,20 @@
|
||||
<FILEKIND>Library</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MsgUtilDebug.lib</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Library</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbView.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
@ -1285,11 +1295,6 @@
|
||||
<PATH>nsAbFactory.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCardDataSource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsDirectoryDataSource.cpp</PATH>
|
||||
@ -1380,11 +1385,6 @@
|
||||
<PATH>nsAbMDBDirProperty.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbMDBRDFResource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbBoolExprToLDAPFilter.cpp</PATH>
|
||||
@ -1470,6 +1470,16 @@
|
||||
<PATH>UnicharUtilsStaticDebug.o</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MsgUtilDebug.lib</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbView.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
<TARGET>
|
||||
@ -1534,6 +1544,16 @@
|
||||
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
|
||||
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
|
||||
</SETTING>
|
||||
<SETTING>
|
||||
<SETTING><NAME>SearchPath</NAME>
|
||||
<SETTING><NAME>Path</NAME><VALUE>:::base:util:macbuild:</VALUE></SETTING>
|
||||
<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
|
||||
<SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
|
||||
</SETTING>
|
||||
<SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
|
||||
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
|
||||
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
|
||||
</SETTING>
|
||||
</SETTING>
|
||||
<SETTING><NAME>SystemSearchPaths</NAME>
|
||||
<SETTING>
|
||||
@ -2401,13 +2421,6 @@
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCardDataSource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsDirectoryDataSource.cpp</PATH>
|
||||
@ -2541,13 +2554,6 @@
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbMDBRDFResource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbBoolExprToLDAPFilter.cpp</PATH>
|
||||
@ -2667,6 +2673,20 @@
|
||||
<FILEKIND>Library</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MsgUtil.lib</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Library</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbView.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
@ -2704,11 +2724,6 @@
|
||||
<PATH>nsAbFactory.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCardDataSource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsDirectoryDataSource.cpp</PATH>
|
||||
@ -2799,11 +2814,6 @@
|
||||
<PATH>nsAbMDBDirProperty.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbMDBRDFResource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbBoolExprToLDAPFilter.cpp</PATH>
|
||||
@ -2889,6 +2899,16 @@
|
||||
<PATH>UnicharUtilsStatic.o</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MsgUtil.lib</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbView.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
</TARGETLIST>
|
||||
@ -2948,18 +2968,6 @@
|
||||
<PATH>nsAbMDBDirProperty.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>MsgAddrbookDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbMDBRDFResource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>MsgAddrbookDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCardDataSource.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>MsgAddrbookDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
@ -3110,6 +3118,12 @@
|
||||
<PATH>nsAbUtils.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>MsgAddrbookDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsAbView.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUP>
|
||||
<GROUP><NAME>build</NAME>
|
||||
<FILEREF>
|
||||
@ -3143,6 +3157,12 @@
|
||||
</GROUP>
|
||||
<GROUP><NAME>NS Libraries</NAME>
|
||||
<GROUP><NAME>Optimized</NAME>
|
||||
<FILEREF>
|
||||
<TARGETNAME>MsgAddrbook.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MsgUtil.lib</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>MsgAddrbook.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
@ -3169,6 +3189,12 @@
|
||||
</FILEREF>
|
||||
</GROUP>
|
||||
<GROUP><NAME>Debug</NAME>
|
||||
<FILEREF>
|
||||
<TARGETNAME>MsgAddrbookDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MsgUtilDebug.lib</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>MsgAddrbookDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
|
@ -881,6 +881,13 @@
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIAbView.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
@ -998,6 +1005,11 @@
|
||||
<PATH>nsIAbLDAPAutoCompFormatter.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIAbView.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
<TARGET>
|
||||
@ -1828,6 +1840,13 @@
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIAbView.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
@ -1945,6 +1964,11 @@
|
||||
<PATH>nsIAbLDAPAutoCompFormatter.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIAbView.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
</TARGETLIST>
|
||||
@ -1955,8 +1979,6 @@
|
||||
</TARGETORDER>
|
||||
|
||||
<GROUPLIST>
|
||||
<GROUP><NAME>Rescued Items</NAME>
|
||||
</GROUP>
|
||||
<FILEREF>
|
||||
<TARGETNAME>headers</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
@ -2095,6 +2117,12 @@
|
||||
<PATH>nsIAbLDAPAutoCompFormatter.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>headers</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIAbView.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUPLIST>
|
||||
|
||||
</PROJECT>
|
||||
|
@ -50,6 +50,7 @@ XPIDLSRCS = \
|
||||
nsIAbDirectoryQuery.idl \
|
||||
nsIAbBooleanExpression.idl \
|
||||
nsIAbDirectorySearch.idl \
|
||||
nsIAbView.idl \
|
||||
$(NULL)
|
||||
ifdef MOZ_LDAP_XPCOM
|
||||
XPIDLSRCS += \
|
||||
|
@ -44,6 +44,7 @@ XPIDLSRCS = \
|
||||
.\nsIAbDirectoryQuery.idl \
|
||||
.\nsIAbBooleanExpression.idl \
|
||||
.\nsIAbDirectorySearch.idl \
|
||||
.\nsIAbView.idl \
|
||||
!if !defined(DISABLE_LDAP)
|
||||
.\nsILDAPPrefsService.idl \
|
||||
.\nsIAbLDAPAutoCompFormatter.idl \
|
||||
|
@ -37,14 +37,6 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIAddrDatabase;
|
||||
|
||||
[ptr] native nsVoidArray(nsVoidArray);
|
||||
|
||||
%{C++
|
||||
#include "nsVoidArray.h"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(97448252-F189-11d4-A422-001083003D0C)]
|
||||
interface nsIAbPreferMailFormat {
|
||||
const unsigned long unknown = 0;
|
||||
@ -54,7 +46,6 @@ interface nsIAbPreferMailFormat {
|
||||
|
||||
[scriptable, uuid(FA5C977F-04C8-11d3-A2EB-001083003D0C)]
|
||||
interface nsIAbCard : nsISupports {
|
||||
|
||||
// Card properties
|
||||
attribute wstring firstName;
|
||||
attribute wstring lastName;
|
||||
@ -93,53 +84,30 @@ interface nsIAbCard : nsISupports {
|
||||
attribute wstring custom4;
|
||||
attribute wstring notes;
|
||||
attribute unsigned long lastModifiedDate;
|
||||
attribute wstring name;
|
||||
|
||||
attribute unsigned long preferMailFormat;
|
||||
attribute boolean isMailList;
|
||||
// If isMailList==true then this string
|
||||
// will contain the URI of the associated
|
||||
// mail list
|
||||
/**
|
||||
* If isMailList is true then mailListURI
|
||||
* will contain the URI of the associated
|
||||
* mail list
|
||||
*/
|
||||
attribute string mailListURI;
|
||||
|
||||
wstring getCardValue(in string attrname);
|
||||
wstring getCardValue(in string name);
|
||||
|
||||
void setCardValue(in string attrname, in wstring value);
|
||||
|
||||
// Copies the card attributes from srcCard
|
||||
void copy(in nsIAbCard srcCard);
|
||||
|
||||
readonly attribute string printCardUrl;
|
||||
|
||||
// Adds a new card to the directory defined by 'uri'
|
||||
// Rename to addCardToDirectory
|
||||
//
|
||||
// Returns an intstance of a card which
|
||||
// is an RDF resource component
|
||||
nsIAbCard addCardToDatabase(in string uri);
|
||||
|
||||
// Behaviour wise this is very similar to the
|
||||
// addCardToDatabase method, except that it
|
||||
// assumes the uri refers to a directory that
|
||||
// is not a mail list
|
||||
// This method is rendundent, droping a card
|
||||
// onto a list should be allowed.
|
||||
// Rename to dropCardToDirectory
|
||||
//
|
||||
// Returns an intstance of a card which
|
||||
// is an RDF resource component
|
||||
nsIAbCard dropCardToDatabase(in string uri);
|
||||
|
||||
// Edits an existing card in the directory defined by 'uri'
|
||||
// Rename to editCardInDirectory
|
||||
// Component will be an RDF card, since it has already
|
||||
// been created
|
||||
//
|
||||
// XXX FIX ME, this should not be a the card, it should be on the addressbook.
|
||||
void editCardToDatabase(in string uri);
|
||||
|
||||
// Not sure what this does. Used by the
|
||||
// card data source for values of collation
|
||||
// properties, somthing to do with locales
|
||||
// and sorting. Gets called when selecting
|
||||
// table headers like Name and Email.
|
||||
wstring getCollationKey(in wstring str);
|
||||
boolean equals(in nsIAbCard card);
|
||||
};
|
||||
|
@ -90,7 +90,6 @@ interface nsIAbDirectory : nsISupports {
|
||||
// Delete the array of cards
|
||||
void deleteCards(in nsISupportsArray cards);
|
||||
|
||||
|
||||
// Check if directory contains card
|
||||
// If the implementation is asynchronous the card
|
||||
// may not yet have arrived. If it is in the process
|
||||
@ -102,15 +101,27 @@ interface nsIAbDirectory : nsISupports {
|
||||
// Check if directory contains directory
|
||||
boolean hasDirectory(in nsIAbDirectory dir);
|
||||
|
||||
// Creates a new card in the directory
|
||||
// with the properties defined by card
|
||||
nsIAbCard addCard(in nsIAbCard card);
|
||||
nsIAbCard dropCard(in nsIAbCard card);
|
||||
/**
|
||||
* return value is the card that got added
|
||||
* we need to do this, as the card we pass in might
|
||||
* be an abstract nsIAbCard, and the caller might need
|
||||
* the "real" card (the mdbcard) to get / set
|
||||
* non-standard card values
|
||||
*/
|
||||
nsIAbCard addCard(in nsIAbCard card);
|
||||
|
||||
void dropCard(in nsIAbCard card, in boolean needToCopyCard);
|
||||
|
||||
// Mail list specific
|
||||
//
|
||||
/**
|
||||
* directory is local (example, mork based) or remote (example, LDAP)
|
||||
*/
|
||||
readonly attribute boolean isRemote;
|
||||
|
||||
// Mail list specific
|
||||
readonly attribute boolean supportsMailingLists;
|
||||
|
||||
// XXX todo
|
||||
// fix this, ugh
|
||||
// This attribute servers two purposes
|
||||
// depending if the directory is a mail list.
|
||||
// If not mail list directories are stored here
|
||||
@ -118,28 +129,28 @@ interface nsIAbDirectory : nsISupports {
|
||||
attribute nsISupportsArray addressLists;
|
||||
|
||||
// Specific to a directory which stores mail lists
|
||||
//
|
||||
|
||||
// Creates a new mailing list in the directory
|
||||
// with the properties defined by list
|
||||
void addMailList (in nsIAbDirectory list);
|
||||
|
||||
// Specific to a directory which is a mail list
|
||||
//
|
||||
|
||||
// listName is not needed, dirName could be used
|
||||
// instead
|
||||
attribute wstring listName;
|
||||
attribute wstring listNickName;
|
||||
attribute wstring description;
|
||||
|
||||
// Adds a new mail list into the directory
|
||||
// defined by the uri
|
||||
/**
|
||||
* Adds a new mail list into the directory
|
||||
* defined by the uri
|
||||
* XXX javadoc me
|
||||
*/
|
||||
void addMailListToDatabase(in string uri);
|
||||
|
||||
// Edits an existing mail in the directory
|
||||
// defined by the uri
|
||||
void editMailListToDatabase(in string uri);
|
||||
/**
|
||||
* Edits an existing mailing list (specified as listCard)
|
||||
* into the directory specified by the uri
|
||||
* XXX javadoc me
|
||||
*/
|
||||
void editMailListToDatabase(in string uri, in nsIAbCard listCard);
|
||||
|
||||
// Copies mail list properties from the srcList
|
||||
void copyMailList(in nsIAbDirectory srcList);
|
||||
@ -157,13 +168,8 @@ interface nsIAbDirectory : nsISupports {
|
||||
void createNewDirectory(in unsigned long prefCount,[array, size_is(prefCount)] in string prefName, [array, size_is(prefCount)] in wstring prefValue);
|
||||
|
||||
/* create a directory by passing the display name and address book uri */
|
||||
void CreateDirectoryByURI(in wstring displayName, in string uri, in boolean migrating);
|
||||
|
||||
// Returns the total number of cards
|
||||
// If the implementation is asynchronous the total number
|
||||
// is representative of the current number of cards obtained
|
||||
// For example a search on LDAP will return card asynchronously
|
||||
// and may take n seconds to complete the search.
|
||||
unsigned long getTotalCards(in boolean subDirectoryCount);
|
||||
void createDirectoryByURI(in wstring displayName, in string uri, in boolean migrating);
|
||||
|
||||
wstring getValueForCard(in nsIAbCard card, in string name);
|
||||
void setValueForCard(in nsIAbCard card, in string name, in wstring value);
|
||||
};
|
||||
|
@ -91,8 +91,7 @@ interface nsIAbDirectoryQueryPropertyValue : nsISupports
|
||||
*
|
||||
* Two further properties are defined that
|
||||
* do not exist as properties on a card.
|
||||
* 'card:URI' which represents the URI property
|
||||
* of the card as an RDF resource
|
||||
*
|
||||
* 'card:nsIAbCard' which represents the interface
|
||||
* of a card component
|
||||
*
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -38,11 +39,19 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIEnumerator.idl"
|
||||
|
||||
typedef unsigned long abListenerNotifyFlagValue;
|
||||
|
||||
[scriptable, uuid(1920E484-0709-11d3-A2EC-001083003D0C)]
|
||||
interface nsIAbListener : nsISupports {
|
||||
const abListenerNotifyFlagValue added = 0x1;
|
||||
void onItemAdded(in nsISupports parentDir, in nsISupports item);
|
||||
|
||||
void onItemAdded(in nsISupports parentDir, in nsISupports item);
|
||||
void onItemRemoved(in nsISupports parentDir, in nsISupports item);
|
||||
void onItemPropertyChanged(in nsISupports item, in string property, in wstring oldValue, in wstring newValue);
|
||||
const abListenerNotifyFlagValue directoryItemRemoved = 0x2;
|
||||
const abListenerNotifyFlagValue directoryRemoved = 0x4;
|
||||
void onItemRemoved(in nsISupports parentDir, in nsISupports item);
|
||||
|
||||
const abListenerNotifyFlagValue changed = 0x8;
|
||||
void onItemPropertyChanged(in nsISupports item, in string property, in wstring oldValue, in wstring newValue);
|
||||
|
||||
const abListenerNotifyFlagValue all = 0xFFFFFFFF;
|
||||
};
|
||||
|
@ -20,7 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s): Paul Sandoz <paul.sandoz@sun.com>
|
||||
* Paul Sandoz <paul.sandoz@sun.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -49,17 +49,10 @@ interface nsIAddrDatabase;
|
||||
|
||||
[scriptable, uuid(5F414A80-1DD2-11B2-AAD0-AA4A15D5A1E8)]
|
||||
interface nsIAbMDBCard : nsISupports {
|
||||
// Possible DB specific methods
|
||||
|
||||
// In current impl these methods set and get
|
||||
// on the same member variable
|
||||
// Used the absync code
|
||||
readonly attribute unsigned long key;
|
||||
void setRecordKey(in unsigned long key);
|
||||
|
||||
// used by the absync code
|
||||
attribute unsigned long key;
|
||||
|
||||
// DB specific methods
|
||||
|
||||
attribute unsigned long dbTableID;
|
||||
attribute unsigned long dbRowID;
|
||||
|
||||
@ -70,34 +63,7 @@ interface nsIAbMDBCard : nsISupports {
|
||||
// a directory listener of an inserted event
|
||||
void copyCard(in nsIAbMDBCard srcCardDB);
|
||||
|
||||
// Used in conjunction with copyCard when
|
||||
// inserting a new card into a directory
|
||||
readonly attribute string cardURI;
|
||||
|
||||
|
||||
// Anonymous card properties
|
||||
// Not really sure what these are for
|
||||
// They do not seem to be used.
|
||||
// May have to move back to nsAbCard interface
|
||||
[noscript] readonly attribute nsVoidArray anonymousStrAttrubutesList;
|
||||
[noscript] readonly attribute nsVoidArray anonymousStrValuesList;
|
||||
[noscript] readonly attribute nsVoidArray anonymousIntAttrubutesList;
|
||||
[noscript] readonly attribute nsVoidArray anonymousIntValuesList;
|
||||
[noscript] readonly attribute nsVoidArray anonymousBoolAttrubutesList;
|
||||
[noscript] readonly attribute nsVoidArray anonymousBoolValuesList;
|
||||
void setAnonymousStringAttribute(in string attrname, in string value);
|
||||
void setAnonymousIntAttribute(in string attrname, in unsigned long value);
|
||||
void setAnonymousBoolAttribute(in string attrname, in boolean value);
|
||||
/*
|
||||
In the current implementation these methods
|
||||
operate on the personal address book.
|
||||
i.e. they are hardcoded to abdirectory://abook.mab
|
||||
Potentialy disasterous if called since they
|
||||
can overwrite the database member variable to point to
|
||||
the personal database.
|
||||
*/
|
||||
void addAnonymousAttributesToDB();
|
||||
void editAnonymousAttributesInDB();
|
||||
|
||||
wstring getStringAttribute(in string name);
|
||||
void setStringAttribute(in string name, in wstring value);
|
||||
};
|
||||
|
||||
|
@ -44,10 +44,6 @@
|
||||
[scriptable, uuid(C6BCF232-1DD1-11B2-A108-B41BFECED134)]
|
||||
interface nsIAbMDBDirectory : nsISupports {
|
||||
|
||||
// Creates an RDF card component given
|
||||
// the uriName
|
||||
nsIAbCard addChildCards(in string uriName);
|
||||
|
||||
// Creates an RDF directory component from the
|
||||
// uriName, adds it to its children and returns
|
||||
// the component
|
||||
|
@ -51,26 +51,40 @@
|
||||
#include "nsIAbDirectory.idl"
|
||||
#include "nsIAbCard.idl"
|
||||
|
||||
interface nsIDOMXULDocument;
|
||||
|
||||
[scriptable, uuid(C5339441-303F-11d3-9E13-00A0C92B5F0D)]
|
||||
interface nsIAddrBookSession : nsISupports {
|
||||
|
||||
void addAddressBookListener(in nsIAbListener listener);
|
||||
void addAddressBookListener(in nsIAbListener listener, in abListenerNotifyFlagValue notifyFlags);
|
||||
void removeAddressBookListener(in nsIAbListener listener);
|
||||
void notifyItemPropertyChanged(in nsISupports item,
|
||||
in string property,
|
||||
in wstring oldValue,
|
||||
in wstring newValue);
|
||||
void notifyDirectoryItemAdded(in nsIAbDirectory directory, in nsISupports item);
|
||||
|
||||
/**
|
||||
* when a card is deleted
|
||||
*/
|
||||
void notifyDirectoryItemDeleted(in nsIAbDirectory directory, in nsISupports item);
|
||||
|
||||
/**
|
||||
* when a directory is deleted
|
||||
*/
|
||||
void notifyDirectoryDeleted(in nsIAbDirectory directory, in nsISupports item);
|
||||
|
||||
[noscript] readonly attribute nsFileSpec userProfileDirectory;
|
||||
|
||||
/**
|
||||
* this is used to flush the pending notifcations on the document
|
||||
* used to be in the msg view navigation service, but that is gone
|
||||
* generate the name from the card, using the firstName and lastName and the displayName
|
||||
*
|
||||
* format follows the "mail.addr_book.lastnamefirst" pref values
|
||||
*
|
||||
* 0 = generated name is displayName
|
||||
* 1 = lastFirst, formatted following lastFirstFormat (see addressBook.properties)
|
||||
* 2 = firstLast, formatted following firstLastFormat (see addressBook.properties)
|
||||
*
|
||||
* we allow the caller to cache the pref value, so we don't have to go to prefs every time.
|
||||
*/
|
||||
void ensureDocumentIsLoaded(in nsIDOMXULDocument xulDocument);
|
||||
wstring generateNameFromCard(in nsIAbCard card, in long generateFormat);
|
||||
};
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -42,15 +43,16 @@
|
||||
|
||||
%{C++
|
||||
#include "mdb.h"
|
||||
#include "nsString.h"
|
||||
%}
|
||||
|
||||
[ptr] native nsIMdbTableRowCursor(nsIMdbTableRowCursor);
|
||||
[ptr] native nsIMdbEnv(nsIMdbEnv);
|
||||
[ptr] native nsIMdbRow(nsIMdbRow);
|
||||
[ref] native nsStringRef(nsString);
|
||||
|
||||
%{C++
|
||||
// note, GeneratedName is not a real column
|
||||
// if you change any of this, make sure to change
|
||||
// Get / Set CardValue in nsAbCardProperty.cpp
|
||||
#define kFirstNameColumn "FirstName"
|
||||
#define kLastNameColumn "LastName"
|
||||
#define kDisplayNameColumn "DisplayName"
|
||||
@ -94,8 +96,18 @@
|
||||
#define kMailListNickName "ListNickName"
|
||||
#define kMailListDescription "ListDescription"
|
||||
#define kMailListTotalAddresses "ListTotalAddresses"
|
||||
|
||||
%}
|
||||
|
||||
[scriptable, uuid(ca536e0e-1dd1-11b2-951a-e02b86e4f60e)]
|
||||
interface nsAddrDBCommitType
|
||||
{
|
||||
const long kSmallCommit = 0;
|
||||
const long kLargeCommit = 1;
|
||||
const long kSessionCommit = 2;
|
||||
const long kCompressCommit = 3;
|
||||
};
|
||||
|
||||
[scriptable, uuid(A4186D8B-1DD0-11d3-A303-001083003D0C)]
|
||||
interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
||||
|
||||
@ -105,47 +117,35 @@ interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
||||
void close(in boolean forceCommit);
|
||||
[noscript] void openMDB(in nsFileSpec dbName, in boolean create);
|
||||
void closeMDB(in boolean commit);
|
||||
void openAnonymousDB(out nsIAddrDatabase pCardDB);
|
||||
void closeAnonymousDB(in boolean forceCommit);
|
||||
|
||||
void commit(in unsigned long commitType);
|
||||
void forceClosed();
|
||||
|
||||
void createNewCardAndAddToDB(in nsIAbCard newCard, in boolean beNotify);
|
||||
void createNewCardAndAddToDBWithKey(in nsIAbCard newCard, in boolean beNotify, out unsigned long key);
|
||||
void createNewListCardAndAddToDB(in unsigned long listRowID, in nsIAbCard newCard, in boolean beNotify);
|
||||
void createMailListAndAddToDB(in nsIAbDirectory newList, in boolean beNotify);
|
||||
void createNewCardAndAddToDB(in nsIAbCard newCard, in boolean aNotify);
|
||||
void createNewCardAndAddToDBWithKey(in nsIAbCard newCard, in boolean aNotify, out unsigned long key);
|
||||
void createNewListCardAndAddToDB(in nsIAbDirectory list, in unsigned long listRowID, in nsIAbCard newCard, in boolean aNotify);
|
||||
void createMailListAndAddToDB(in nsIAbDirectory newList, in boolean aNotify);
|
||||
nsIEnumerator enumerateCards(in nsIAbDirectory directory);
|
||||
nsIEnumerator enumerateListAddresses(in nsIAbDirectory directory);
|
||||
void getMailingListsFromDB(in nsIAbDirectory parentDir);
|
||||
void deleteCard(in nsIAbCard card, in boolean beNotify);
|
||||
void editCard(in nsIAbCard card, in boolean beNotify);
|
||||
void deleteCard(in nsIAbCard card, in boolean aNotify);
|
||||
void editCard(in nsIAbCard card, in boolean aNotify);
|
||||
boolean containsCard(in nsIAbCard card);
|
||||
void deleteMailList(in nsIAbDirectory mailList, in boolean beNotify);
|
||||
void editMailList(in nsIAbDirectory mailList, in boolean beNotify);
|
||||
void deleteMailList(in nsIAbDirectory mailList, in boolean aNotify);
|
||||
void editMailList(in nsIAbDirectory mailList, in nsIAbCard listCard, in boolean aNotify);
|
||||
boolean containsMailList(in nsIAbDirectory mailList);
|
||||
void deleteCardFromMailList(in nsIAbDirectory mailList, in nsIAbCard card, in boolean beNotify);
|
||||
wstring getDirectoryName();
|
||||
void deleteCardFromMailList(in nsIAbDirectory mailList, in nsIAbCard card, in boolean aNotify);
|
||||
readonly attribute wstring directoryName;
|
||||
|
||||
nsIAbCard getCardForEmailAddress(in nsIAbDirectory directory, in string emailAddress);
|
||||
/**
|
||||
* aUTF8Value needs to be in UTF-8
|
||||
*/
|
||||
nsIAbCard getCardFromAttribute(in nsIAbDirectory directory, in string aName, in string aUTF8Value, in boolean caseInsensitive);
|
||||
|
||||
PRBool findMailListbyUnicodeName(in wstring listName);
|
||||
|
||||
void getCardCount(out PRUint32 count);
|
||||
void RemoveExtraCardsInCab(in PRUint32 cardTotal, in PRUint32 cabMax);
|
||||
|
||||
void setAnonymousStringAttribute(in string attrname, in string value);
|
||||
string getAnonymousStringAttribute(in string attrname);
|
||||
void setAnonymousIntAttribute(in string attrname, in unsigned long value);
|
||||
unsigned long getAnonymousIntAttribute(in string attrname);
|
||||
void setAnonymousBoolAttribute(in string attrname, in boolean value);
|
||||
boolean getAnonymousBoolAttribute(in string attrname);
|
||||
void addAnonymousAttributesToDB();
|
||||
void removeAnonymousAttributesFromDB();
|
||||
void editAnonymousAttributesInDB();
|
||||
void addAnonymousAttributesFromCard(in nsIAbCard card);
|
||||
void removeAnonymousAttributesFromCard(in nsIAbCard card);
|
||||
void editAnonymousAttributesFromCard(in nsIAbCard card);
|
||||
void removeExtraCardsInCab(in PRUint32 cardTotal, in PRUint32 cabMax);
|
||||
|
||||
[noscript] readonly attribute nsIMdbRow newRow;
|
||||
[noscript] readonly attribute nsIMdbRow newListRow;
|
||||
@ -192,8 +192,12 @@ interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
||||
[noscript] void addListName(in nsIMdbRow row, in string value);
|
||||
[noscript] void addListNickName(in nsIMdbRow row, in string value);
|
||||
[noscript] void addListDescription(in nsIMdbRow row, in string value);
|
||||
[noscript] void AddListDirNode(in nsIMdbRow listRow);
|
||||
|
||||
[noscript] void createCollationKey(in wstring sourceStr, in nsStringRef resultStr);
|
||||
[noscript] void addListDirNode(in nsIMdbRow listRow);
|
||||
|
||||
/**
|
||||
* use for getting and setting generic string attributes
|
||||
* like _AimScreenName
|
||||
*/
|
||||
void setCardValue(in nsIAbCard card, in string name, in wstring value, in boolean notify);
|
||||
wstring getCardValue(in nsIAbCard card, in string name);
|
||||
};
|
||||
|
@ -40,29 +40,25 @@
|
||||
#include "nsIAddrDatabase.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
|
||||
|
||||
interface nsIDOMWindowInternal;
|
||||
interface nsIDOMXULElement;
|
||||
interface nsIDOMNodeList;
|
||||
interface nsIFileSpec;
|
||||
interface nsIAbDirectory;
|
||||
|
||||
[scriptable, uuid(D60B84F1-2A8C-11d3-9E07-00A0C92B5F0D)]
|
||||
interface nsIAddressBook : nsISupports {
|
||||
|
||||
void deleteCards(in nsIDOMXULElement tree, in nsIDOMXULElement srcDir, in nsIDOMNodeList node);
|
||||
void newAddressBook(in nsIRDFCompositeDataSource db, in nsIDOMXULElement srcDir, in unsigned long prefCount,[array, size_is(prefCount)] in string prefName, [array, size_is(prefCount)] in wstring prefValue);
|
||||
interface nsIAddressBook : nsISupports
|
||||
{
|
||||
void newAddressBook(in nsIRDFCompositeDataSource db, in unsigned long prefCount,[array, size_is(prefCount)] in string prefName, [array, size_is(prefCount)] in wstring prefValue);
|
||||
void deleteAddressBooks(in nsIRDFCompositeDataSource db, in nsISupportsArray parentDir, in nsIDOMNodeList node);
|
||||
void printCard();
|
||||
void printAddressbook();
|
||||
void setDocShellWindow(in nsIDOMWindowInternal win);
|
||||
void importAddressBook();
|
||||
void exportAddressBook(in nsIAbDirectory aDirectory);
|
||||
void convertLDIFtoMAB(in nsIFileSpec fileSpec, in boolean migrating, in nsIAddrDatabase db, in boolean bStoreLocAsHome, in boolean bImportingComm4x);
|
||||
void convertNA2toLDIF(in nsIFileSpec srcFileSpec, in nsIFileSpec dstFileSpec);
|
||||
void getAbDatabaseFromURI(in string URI, out nsIAddrDatabase db);
|
||||
boolean mailListNameExistsInDB(in wstring name, in string URI);
|
||||
boolean mailListNameExists(in wstring name);
|
||||
unsigned long getTotalCards(in string URI);
|
||||
|
||||
void createCollationKey(in wstring source, out wstring result);
|
||||
nsIAddrDatabase getAbDatabaseFromURI(in string URI);
|
||||
boolean mailListNameExistsInDB(in wstring name, in string URI);
|
||||
boolean mailListNameExists(in wstring name);
|
||||
};
|
||||
|
||||
|
@ -30,7 +30,6 @@ abCommon.js
|
||||
abDirTreeOverlay.xul
|
||||
abEditCardDialog.xul
|
||||
abNewCardDialog.xul
|
||||
abResultsTreeOverlay.xul
|
||||
abSelectAddressesDialog.js
|
||||
abSelectAddressesDialog.xul
|
||||
addressbook.js
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -37,7 +38,7 @@
|
||||
|
||||
var editCard;
|
||||
var gOnSaveListeners = new Array;
|
||||
|
||||
var gOkCallback = null;
|
||||
var gAddressBookBundle;
|
||||
|
||||
function OnLoadNewCard()
|
||||
@ -46,19 +47,36 @@ function OnLoadNewCard()
|
||||
|
||||
doSetOKCancel(NewCardOKButton, 0);
|
||||
|
||||
var cardproperty = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance();
|
||||
cardproperty = cardproperty.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
var cardproperty = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance(Components.interfaces.nsIAbCard);
|
||||
|
||||
editCard.card = cardproperty;
|
||||
editCard.okCallback = 0;
|
||||
editCard.titleProperty = "newCardTitle"
|
||||
|
||||
if ("arguments" in window && window.arguments[0])
|
||||
{
|
||||
if ("selectedAB" in window.arguments[0])
|
||||
if ("selectedAB" in window.arguments[0]) {
|
||||
// check if selected ab is a mailing list
|
||||
var abURI = window.arguments[0].selectedAB;
|
||||
|
||||
var directory = GetDirectoryFromURI(abURI);
|
||||
if (directory.isMailList) {
|
||||
var parentURI = GetParentDirectoryFromMailingListURI(abURI);
|
||||
if (parentURI) {
|
||||
editCard.selectedAB = parentURI;
|
||||
}
|
||||
else {
|
||||
// it's a mailing list, but we failed to determine the parent directory
|
||||
// use the personal addressbook
|
||||
editCard.selectedAB = kPersonalAddressbookURI;
|
||||
}
|
||||
}
|
||||
else {
|
||||
editCard.selectedAB = window.arguments[0].selectedAB;
|
||||
else
|
||||
editCard.selectedAB = "moz-abmdbdirectory://abook.mab";
|
||||
}
|
||||
}
|
||||
else {
|
||||
editCard.selectedAB = kPersonalAddressbookURI;
|
||||
}
|
||||
|
||||
// we may have been given properties to pre-initialize the window with....
|
||||
// we'll fill these in here...
|
||||
@ -96,8 +114,8 @@ function OnLoadNewCard()
|
||||
|
||||
GetCardValues(editCard.card, document);
|
||||
|
||||
//// FIX ME - looks like we need to focus on both the text field and the tab widget
|
||||
//// probably need to do the same in the addressing widget
|
||||
// FIX ME - looks like we need to focus on both the text field and the tab widget
|
||||
// probably need to do the same in the addressing widget
|
||||
|
||||
// focus on first name
|
||||
var firstName = document.getElementById('FirstName');
|
||||
@ -107,6 +125,22 @@ function OnLoadNewCard()
|
||||
}
|
||||
|
||||
|
||||
function EditCardOKButton()
|
||||
{
|
||||
SetCardValues(editCard.card, document);
|
||||
|
||||
editCard.card.editCardToDatabase(editCard.abURI);
|
||||
|
||||
NotifySaveListeners();
|
||||
|
||||
// callback to allow caller to update
|
||||
if (gOkCallback)
|
||||
gOkCallback();
|
||||
|
||||
return true; // close the window
|
||||
}
|
||||
|
||||
|
||||
function OnLoadEditCard()
|
||||
{
|
||||
InitEditCard();
|
||||
@ -118,11 +152,9 @@ function OnLoadEditCard()
|
||||
if ( window.arguments[0].card )
|
||||
editCard.card = window.arguments[0].card;
|
||||
if ( window.arguments[0].okCallback )
|
||||
editCard.okCallback = window.arguments[0].okCallback;
|
||||
gOkCallback = window.arguments[0].okCallback;
|
||||
if ( window.arguments[0].abURI )
|
||||
editCard.abURI = window.arguments[0].abURI;
|
||||
if ( window.arguments[0].abCardURI )
|
||||
editCard.abCardURI = window.arguments[0].abCardURI;
|
||||
}
|
||||
|
||||
// set global state variables
|
||||
@ -141,13 +173,17 @@ function OnLoadEditCard()
|
||||
[ displayName ]);
|
||||
}
|
||||
|
||||
// this is used by people who extend the ab card dialog
|
||||
// like Netscape does for screenname
|
||||
function RegisterSaveListener(func)
|
||||
{
|
||||
var length = gOnSaveListeners.length;
|
||||
gOnSaveListeners[length] = func;
|
||||
}
|
||||
|
||||
function CallSaveListeners()
|
||||
// this is used by people who extend the ab card dialog
|
||||
// like Netscape does for screenname
|
||||
function NotifySaveListeners()
|
||||
{
|
||||
for ( var i = 0; i < gOnSaveListeners.length; i++ )
|
||||
gOnSaveListeners[i]();
|
||||
@ -159,30 +195,15 @@ function InitEditCard()
|
||||
// create editCard object that contains global variables for editCard.js
|
||||
editCard = new Object;
|
||||
|
||||
// get pointer to nsIPref object
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"];
|
||||
if ( prefs )
|
||||
{
|
||||
prefs = prefs.getService();
|
||||
if ( prefs )
|
||||
{
|
||||
prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
editCard.prefs = prefs;
|
||||
}
|
||||
}
|
||||
editCard.prefs = gPrefs;
|
||||
|
||||
// get specific prefs that editCard will need
|
||||
if ( prefs )
|
||||
{
|
||||
try {
|
||||
editCard.displayLastNameFirst = prefs.getBoolPref("mail.addr_book.displayName.lastnamefirst");
|
||||
editCard.generateDisplayName = prefs.getBoolPref("mail.addr_book.displayName.autoGeneration");
|
||||
editCard.lastFirstSeparator = ", ";
|
||||
editCard.firstLastSeparator = " ";
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to get pref\n");
|
||||
}
|
||||
try {
|
||||
editCard.displayLastNameFirst = gPrefs.getBoolPref("mail.addr_book.displayName.lastnamefirst");
|
||||
editCard.generateDisplayName = gPrefs.getBoolPref("mail.addr_book.displayName.autoGeneration");
|
||||
}
|
||||
catch (ex) {
|
||||
dump("ex: failed to get pref" + ex + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,29 +223,21 @@ function NewCardOKButton()
|
||||
if ( editCard.card )
|
||||
{
|
||||
SetCardValues(editCard.card, document);
|
||||
editCard.card.addCardToDatabase(uri);
|
||||
CallSaveListeners();
|
||||
|
||||
var directory = GetDirectoryFromURI(uri);
|
||||
|
||||
// replace editCard.card with the card we added
|
||||
// so that save listeners can get / set attributes on
|
||||
// the card that got created.
|
||||
var addedCard = directory.addCard(editCard.card);
|
||||
editCard.card = addedCard;
|
||||
NotifySaveListeners();
|
||||
}
|
||||
}
|
||||
|
||||
return true; // close the window
|
||||
}
|
||||
|
||||
function EditCardOKButton()
|
||||
{
|
||||
SetCardValues(editCard.card, document);
|
||||
|
||||
editCard.card.editCardToDatabase(editCard.abURI);
|
||||
CallSaveListeners();
|
||||
|
||||
// callback to allow caller to update
|
||||
if ("okCallback" in editCard)
|
||||
editCard.okCallback();
|
||||
|
||||
return true; // close the window
|
||||
}
|
||||
|
||||
|
||||
// Move the data from the cardproperty to the dialog
|
||||
function GetCardValues(cardproperty, doc)
|
||||
{
|
||||
@ -275,7 +288,6 @@ function GetCardValues(cardproperty, doc)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Move the data from the dialog to the cardproperty to be stored in the database
|
||||
function SetCardValues(cardproperty, doc)
|
||||
{
|
||||
@ -362,22 +374,16 @@ function GenerateDisplayName()
|
||||
var lastNameField = document.getElementById('LastName');
|
||||
var displayNameField = document.getElementById('DisplayName');
|
||||
|
||||
/* todo: i18N work todo here */
|
||||
/* this used to be XP_GetString(MK_ADDR_FIRST_LAST_SEP) */
|
||||
|
||||
var separator = "";
|
||||
if ( lastNameField.value && firstNameField.value )
|
||||
{
|
||||
if (lastNameField.value && firstNameField.value) {
|
||||
if ( editCard.displayLastNameFirst )
|
||||
separator = editCard.lastFirstSeparator;
|
||||
displayName = gAddressBookBundle.getFormattedString("lastFirstFormat",[ lastNameField.value, firstNameField.value ]);
|
||||
else
|
||||
separator = editCard.firstLastSeparator;
|
||||
displayName = gAddressBookBundle.getFormattedString("firstLastFormat",[ firstNameField.value, lastNameField.value ]);
|
||||
}
|
||||
else {
|
||||
// one (or both) of these is empty, so this works.
|
||||
displayName = firstNameField.value + lastNameField.value;
|
||||
}
|
||||
|
||||
if ( editCard.displayLastNameFirst )
|
||||
displayName = lastNameField.value + separator + firstNameField.value;
|
||||
else
|
||||
displayName = firstNameField.value + separator + lastNameField.value;
|
||||
|
||||
displayNameField.value = displayName;
|
||||
top.window.title = gAddressBookBundle.getFormattedString(editCard.titleProperty,
|
||||
|
@ -31,6 +31,7 @@ Rights Reserved.
|
||||
</stringbundleset>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abCommon.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abCardOverlay.js"/>
|
||||
|
||||
<vbox id="editcard">
|
||||
|
@ -16,13 +16,21 @@
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Paul Hangas <hangas@netscape.com>
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
* Paul Hangas <hangas@netscape.com>
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*/
|
||||
|
||||
//NOTE: gAddressBookBundle must be defined and set or this Overlay won't work
|
||||
|
||||
var gPrefs = Components.classes["@mozilla.org/preferences-service;1"];
|
||||
gPrefs = gPrefs.getService();
|
||||
gPrefs = gPrefs.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
var gAddrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);
|
||||
|
||||
var zName;
|
||||
var zNickname;
|
||||
var zDisplayName;
|
||||
@ -36,7 +44,6 @@ var zCustom2;
|
||||
var zCustom3;
|
||||
var zCustom4;
|
||||
|
||||
var rdf;
|
||||
var cvData;
|
||||
|
||||
function OnLoadCardView()
|
||||
@ -54,9 +61,6 @@ function OnLoadCardView()
|
||||
zCustom3 = gAddressBookBundle.getString("propertyCustom3") + ": ";
|
||||
zCustom4 = gAddressBookBundle.getString("propertyCustom4") + ": ";
|
||||
|
||||
rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
|
||||
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
|
||||
var doc = document;
|
||||
|
||||
/* data for address book, prefixes: "cvb" = card view box
|
||||
@ -75,6 +79,8 @@ function OnLoadCardView()
|
||||
cvData.cvDisplayName = doc.getElementById("cvDisplayName");
|
||||
cvData.cvEmail1Box = doc.getElementById("cvEmail1Box");
|
||||
cvData.cvEmail1 = doc.getElementById("cvEmail1");
|
||||
cvData.cvListNameBox = doc.getElementById("cvListNameBox");
|
||||
cvData.cvListName = doc.getElementById("cvListName");
|
||||
cvData.cvEmail2Box = doc.getElementById("cvEmail2Box");
|
||||
cvData.cvEmail2 = doc.getElementById("cvEmail2");
|
||||
// Home section
|
||||
@ -84,6 +90,8 @@ function OnLoadCardView()
|
||||
cvData.cvHomeAddress2 = doc.getElementById("cvHomeAddress2");
|
||||
cvData.cvHomeCityStZip = doc.getElementById("cvHomeCityStZip");
|
||||
cvData.cvHomeCountry = doc.getElementById("cvHomeCountry");
|
||||
cvData.cvbHomeMapItBox = doc.getElementById("cvbHomeMapItBox");
|
||||
cvData.cvHomeMapIt = doc.getElementById("cvHomeMapIt");
|
||||
cvData.cvHomeWebPageBox = doc.getElementById("cvHomeWebPageBox");
|
||||
cvData.cvHomeWebPage = doc.getElementById("cvHomeWebPage");
|
||||
// Other section
|
||||
@ -94,6 +102,14 @@ function OnLoadCardView()
|
||||
cvData.cvCustom3 = doc.getElementById("cvCustom3");
|
||||
cvData.cvCustom4 = doc.getElementById("cvCustom4");
|
||||
cvData.cvNotes = doc.getElementById("cvNotes");
|
||||
// Description section (mailing lists only)
|
||||
cvData.cvbDescription = doc.getElementById("cvbDescription");
|
||||
cvData.cvhDescription = doc.getElementById("cvhDescription");
|
||||
cvData.cvDescription = doc.getElementById("cvDescription");
|
||||
// Addresses section (mailing lists only)
|
||||
cvData.cvbAddresses = doc.getElementById("cvbAddresses");
|
||||
cvData.cvhAddresses = doc.getElementById("cvhAddresses");
|
||||
cvData.cvAddresses = doc.getElementById("cvAddresses");
|
||||
// Phone section
|
||||
cvData.cvbPhone = doc.getElementById("cvbPhone");
|
||||
cvData.cvhPhone = doc.getElementById("cvhPhone");
|
||||
@ -112,76 +128,108 @@ function OnLoadCardView()
|
||||
cvData.cvWorkAddress2 = doc.getElementById("cvWorkAddress2");
|
||||
cvData.cvWorkCityStZip = doc.getElementById("cvWorkCityStZip");
|
||||
cvData.cvWorkCountry = doc.getElementById("cvWorkCountry");
|
||||
cvData.cvbWorkMapItBox = doc.getElementById("cvbWorkMapItBox");
|
||||
cvData.cvWorkMapIt = doc.getElementById("cvWorkMapIt");
|
||||
cvData.cvWorkWebPageBox = doc.getElementById("cvWorkWebPageBox");
|
||||
cvData.cvWorkWebPage = doc.getElementById("cvWorkWebPage");
|
||||
}
|
||||
|
||||
function DisplayCardViewPane(abNode)
|
||||
// XXX todo
|
||||
// some similar code (in spirit) already exists, see OnLoadEditList()
|
||||
// perhaps we could combine and put in abCommon.js?
|
||||
function GetAddressesFromURI(uri)
|
||||
{
|
||||
var uri = abNode.getAttribute('id');
|
||||
var cardResource = top.rdf.GetResource(uri);
|
||||
var card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
|
||||
// name
|
||||
var name;
|
||||
var separator = "";
|
||||
if ( card.lastName && card.firstName )
|
||||
{
|
||||
// get seperator for display format "First Last"
|
||||
if ( cvPrefs.nameColumn == kFirstNameFirst ) {
|
||||
separator = cvPrefs.firstLastSeparator;
|
||||
}
|
||||
// for seperator all other display formats
|
||||
else {
|
||||
separator = cvPrefs.lastFirstSeparator;
|
||||
var addresses = "";
|
||||
|
||||
var editList = GetDirectoryFromURI(uri);
|
||||
var addressList = editList.addressLists;
|
||||
if (addressList) {
|
||||
var total = addressList.Count();
|
||||
if (total > 0)
|
||||
addresses = addressList.GetElementAt(0).QueryInterface(Components.interfaces.nsIAbCard).primaryEmail;
|
||||
for (var i = 1; i < total; i++ ) {
|
||||
addresses += "," + addressList.GetElementAt(i).QueryInterface(Components.interfaces.nsIAbCard).primaryEmail;
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
switch (cvPrefs.nameColumn) {
|
||||
case kFirstNameFirst:
|
||||
name = card.firstName + separator + card.lastName;
|
||||
break;
|
||||
case kLastNameFirst:
|
||||
name = card.lastName + separator + card.firstName;
|
||||
break;
|
||||
case kDisplayName:
|
||||
default:
|
||||
name = card.displayName;
|
||||
break;
|
||||
}
|
||||
|
||||
var cardTitle = card.name;
|
||||
var nameHeader = name;
|
||||
|
||||
if ( !nameHeader )
|
||||
nameHeader = zName;
|
||||
function DisplayCardViewPane(card)
|
||||
{
|
||||
var generatedName = gAddrbookSession.generateNameFromCard(card, gPrefs.getIntPref("mail.addr_book.lastnamefirst"));
|
||||
|
||||
var data = top.cvData;
|
||||
var visible;
|
||||
var data = top.cvData;
|
||||
var visible;
|
||||
|
||||
// set fields in card view pane
|
||||
var titleString;
|
||||
if (generatedName == "")
|
||||
titleString = card.primaryEmail; // if no generatedName, use email
|
||||
else
|
||||
titleString = generatedName;
|
||||
|
||||
cvSetNode(data.CardTitle, gAddressBookBundle.getFormattedString("viewCardTitle", [ cardTitle]));
|
||||
// set fields in card view pane
|
||||
if (card.isMailList)
|
||||
cvSetNode(data.CardTitle, gAddressBookBundle.getFormattedString("viewListTitle", [generatedName]));
|
||||
else
|
||||
cvSetNode(data.CardTitle, gAddressBookBundle.getFormattedString("viewCardTitle", [titleString]));
|
||||
|
||||
// Name section
|
||||
cvSetNode(data.cvhName, nameHeader);
|
||||
cvSetNode(data.cvhName, titleString);
|
||||
cvSetNodeWithLabel(data.cvNickname, zNickname, card.nickName);
|
||||
cvSetNodeWithLabel(data.cvDisplayName, zDisplayName, card.displayName);
|
||||
|
||||
visible = HandleLink(data.cvEmail1, card.primaryEmail, data.cvEmail1Box, "mailto:") || visible;
|
||||
if (card.isMailList) {
|
||||
// email1 and display name always hidden when a mailing list.
|
||||
cvSetVisible(data.cvEmail1Box, false);
|
||||
cvSetVisible(data.cvDisplayName, false);
|
||||
|
||||
visible = HandleLink(data.cvEmail2, card.secondEmail, data.cvEmail2Box, "mailto:") || visible;
|
||||
visible = HandleLink(data.cvListName, card.displayName, data.cvListNameBox, "mailto:" + escape(GenerateAddressFromCard(card))) || visible;
|
||||
}
|
||||
else {
|
||||
// listname always hidden if not a mailing list
|
||||
cvSetVisible(data.cvListNameBox, false);
|
||||
cvSetNodeWithLabel(data.cvDisplayName, zDisplayName, card.displayName);
|
||||
visible = HandleLink(data.cvEmail1, card.primaryEmail, data.cvEmail1Box, "mailto:" + card.primaryEmail) || visible;
|
||||
}
|
||||
|
||||
visible = HandleLink(data.cvEmail2, card.secondEmail, data.cvEmail2Box, "mailto:" + card.secondEmail) || visible;
|
||||
|
||||
// Home section
|
||||
visible = cvSetNode(data.cvHomeAddress, card.homeAddress);
|
||||
visible = cvSetNode(data.cvHomeAddress2, card.homeAddress2) || visible;
|
||||
visible = cvSetCityStateZip(data.cvHomeCityStZip, card.homeCity, card.homeState, card.homeZipCode) || visible;
|
||||
visible = cvSetNode(data.cvHomeCountry, card.homeCountry) || visible;
|
||||
if (visible) {
|
||||
var homeMapItUrl = CreateMapItURL(card.homeAddress, card.homeAddress2, card.homeCity, card.homeState, card.homeZipCode, card.homeCountry);
|
||||
if (homeMapItUrl) {
|
||||
cvSetVisible(data.cvbHomeMapItBox, true);
|
||||
data.cvHomeMapIt.setAttribute('url', homeMapItUrl);
|
||||
}
|
||||
else {
|
||||
cvSetVisible(data.cvbHomeMapItBox, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cvSetVisible(data.cvbHomeMapItBox, false);
|
||||
}
|
||||
|
||||
visible = HandleLink(data.cvHomeWebPage, card.webPage2, data.cvHomeWebPageBox, "") || visible;
|
||||
visible = HandleLink(data.cvHomeWebPage, card.webPage2, data.cvHomeWebPageBox, card.webPage2) || visible;
|
||||
|
||||
cvSetVisible(data.cvhHome, visible);
|
||||
cvSetVisible(data.cvbHome, visible);
|
||||
if (card.isMailList) {
|
||||
// Description section
|
||||
visible = cvSetNode(data.cvDescription, card.notes)
|
||||
cvSetVisible(data.cvbDescription, visible);
|
||||
|
||||
// Addresses section
|
||||
var addresses = GetAddressesFromURI(card.mailListURI);
|
||||
visible = cvSetNode(data.cvAddresses, addresses)
|
||||
cvSetVisible(data.cvbAddresses, visible);
|
||||
|
||||
// Other section, not shown for mailing lists.
|
||||
cvSetVisible(data.cvbOther, false);
|
||||
}
|
||||
else {
|
||||
// Other section
|
||||
visible = cvSetNodeWithLabel(data.cvCustom1, zCustom1, card.custom1);
|
||||
visible = cvSetNodeWithLabel(data.cvCustom2, zCustom2, card.custom2) || visible;
|
||||
@ -190,6 +238,14 @@ function DisplayCardViewPane(abNode)
|
||||
visible = cvSetNode(data.cvNotes, card.notes) || visible;
|
||||
cvSetVisible(data.cvhOther, visible);
|
||||
cvSetVisible(data.cvbOther, visible);
|
||||
|
||||
// hide description section, not show for non-mailing lists
|
||||
cvSetVisible(data.cvbDescription, false);
|
||||
|
||||
// hide addresses section, not show for non-mailing lists
|
||||
cvSetVisible(data.cvbAddresses, false);
|
||||
}
|
||||
|
||||
// Phone section
|
||||
visible = cvSetNodeWithLabel(data.cvPhWork, zWork, card.workPhone);
|
||||
visible = cvSetNodeWithLabel(data.cvPhHome, zHome, card.homePhone) || visible;
|
||||
@ -202,12 +258,28 @@ function DisplayCardViewPane(abNode)
|
||||
visible = cvSetNode(data.cvJobTitle, card.jobTitle);
|
||||
visible = cvSetNode(data.cvDepartment, card.department) || visible;
|
||||
visible = cvSetNode(data.cvCompany, card.company) || visible;
|
||||
visible = cvSetNode(data.cvWorkAddress, card.workAddress) || visible;
|
||||
visible = cvSetNode(data.cvWorkAddress2, card.workAddress2) || visible;
|
||||
visible = cvSetCityStateZip(data.cvWorkCityStZip, card.workCity, card.workState, card.workZipCode) || visible;
|
||||
visible = cvSetNode(data.cvWorkCountry, card.workCountry) || visible;
|
||||
|
||||
var addressVisible = cvSetNode(data.cvWorkAddress, card.workAddress);
|
||||
addressVisible = cvSetNode(data.cvWorkAddress2, card.workAddress2) || addressVisible;
|
||||
addressVisible = cvSetCityStateZip(data.cvWorkCityStZip, card.workCity, card.workState, card.workZipCode) || addressVisible;
|
||||
addressVisible = cvSetNode(data.cvWorkCountry, card.workCountry) || addressVisible;
|
||||
|
||||
visible = HandleLink(data.cvWorkWebPage, card.webPage1, data.cvWorkWebPageBox, "") || visible;
|
||||
if (addressVisible) {
|
||||
var workMapItUrl = CreateMapItURL(card.workAddress, card.workAddress2, card.workCity, card.workState, card.workZipCode, card.workCountry);
|
||||
data.cvWorkMapIt.setAttribute('url', workMapItUrl);
|
||||
if (workMapItUrl) {
|
||||
cvSetVisible(data.cvbWorkMapItBox, true);
|
||||
data.cvWorkMapIt.setAttribute('url', workMapItUrl);
|
||||
}
|
||||
else {
|
||||
cvSetVisible(data.cvbWorkMapItBox, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cvSetVisible(data.cvbWorkMapItBox, false);
|
||||
}
|
||||
|
||||
visible = HandleLink(data.cvWorkWebPage, card.webPage1, data.cvWorkWebPageBox, card.webPage1) || addressVisible || visible;
|
||||
|
||||
cvSetVisible(data.cvhWork, visible);
|
||||
cvSetVisible(data.cvbWork, visible);
|
||||
@ -280,16 +352,37 @@ function cvSetVisible(node, visible)
|
||||
node.setAttribute("collapsed", "true");
|
||||
}
|
||||
|
||||
function HandleLink(node, value, box, prefix)
|
||||
function HandleLink(node, value, box, link)
|
||||
{
|
||||
var visible = cvSetNode(node, value);
|
||||
if (visible)
|
||||
node.setAttribute('href', prefix + value);
|
||||
node.setAttribute('href', link);
|
||||
cvSetVisible(box, visible);
|
||||
|
||||
return visible;
|
||||
}
|
||||
|
||||
function MapIt(id)
|
||||
{
|
||||
var button = document.getElementById(id);
|
||||
openTopWin(button.getAttribute('url'));
|
||||
}
|
||||
|
||||
function CreateMapItURL(address1, address2, city, state, zip, country)
|
||||
{
|
||||
var urlFormat = gPrefs.getCharPref("mail.addr_book.mapit_url.format");
|
||||
if (!urlFormat)
|
||||
return null;
|
||||
|
||||
urlFormat = urlFormat.replace("@A1", escape(address1));
|
||||
urlFormat = urlFormat.replace("@A2", escape(address2));
|
||||
urlFormat = urlFormat.replace("@CO", escape(country));
|
||||
urlFormat = urlFormat.replace("@CI", escape(city));
|
||||
urlFormat = urlFormat.replace("@ST", escape(state));
|
||||
urlFormat = urlFormat.replace("@ZI", escape(zip));
|
||||
|
||||
return urlFormat;
|
||||
}
|
||||
|
||||
function openLink(id)
|
||||
{
|
||||
|
@ -31,40 +31,57 @@ Rights Reserved.
|
||||
|
||||
<vbox id="CardViewInnerBox" collapsed="true" flex="1">
|
||||
|
||||
<description hide="true" id="CardTitle"/>
|
||||
<description id="CardTitle"/>
|
||||
|
||||
<hbox style="width:100%" flex="1">
|
||||
|
||||
<vbox flex="1" style="width:200px">
|
||||
<vbox id="cvbName" class="cardViewGroup">
|
||||
<description class="CardViewHeading" hide="true" id="cvhName"/>
|
||||
<description class="CardViewText" hide="true" id="cvDisplayName"/>
|
||||
<description class="CardViewText" hide="true" id="cvNickname"/>
|
||||
<description class="CardViewLink" hide="true" id="cvEmail1Box">
|
||||
<html:p><html:a href="" id="cvEmail1"/></html:p></description>
|
||||
<description class="CardViewLink" hide="true" id="cvEmail2Box">
|
||||
<html:p><html:a href="" id="cvEmail2"/>
|
||||
</html:p></description>
|
||||
<description class="CardViewHeading" id="cvhName"/>
|
||||
<description class="CardViewLink" id="cvListNameBox">
|
||||
<html:p><html:a href="" id="cvListName"/></html:p>
|
||||
</description>
|
||||
<description class="CardViewText" id="cvDisplayName"/>
|
||||
<description class="CardViewText" id="cvNickname"/>
|
||||
<description class="CardViewLink" id="cvEmail1Box">
|
||||
<html:p><html:a href="" id="cvEmail1"/></html:p>
|
||||
</description>
|
||||
<description class="CardViewLink" id="cvEmail2Box">
|
||||
<html:p><html:a href="" id="cvEmail2"/></html:p>
|
||||
</description>
|
||||
</vbox>
|
||||
|
||||
<vbox id="cvbHome" class="cardViewGroup">
|
||||
<description class="CardViewHeading" hide="true" id="cvhHome">&home.heading;</description>
|
||||
<description class="CardViewText" hide="true" id="cvHomeAddress"/>
|
||||
<description class="CardViewText" hide="true" id="cvHomeAddress2"/>
|
||||
<description class="CardViewText" hide="true" id="cvHomeCityStZip"/>
|
||||
<description class="CardViewText" hide="true" id="cvHomeCountry"/>
|
||||
<description class="CardViewLink" hide="true" id="cvHomeWebPageBox">
|
||||
<html:p><html:a onclick="return openLink('cvHomeWebPage');" href="" id="cvHomeWebPage"/>
|
||||
</html:p></description>
|
||||
<description class="CardViewHeading" id="cvhHome">&home.heading;</description>
|
||||
<description class="CardViewText" id="cvHomeAddress"/>
|
||||
<description class="CardViewText" id="cvHomeAddress2"/>
|
||||
<description class="CardViewText" id="cvHomeCityStZip"/>
|
||||
<description class="CardViewText" id="cvHomeCountry"/>
|
||||
<hbox id="cvbHomeMapItBox" autostretch="never">
|
||||
<button id="cvHomeMapIt" url="" label="&mapItButton.label;" onclick="MapIt('cvHomeMapIt');"/>
|
||||
</hbox>
|
||||
<description class="CardViewLink" id="cvHomeWebPageBox">
|
||||
<html:p><html:a onclick="return openLink('cvHomeWebPage');" href="" id="cvHomeWebPage"/></html:p>
|
||||
</description>
|
||||
</vbox>
|
||||
|
||||
<vbox id="cvbOther" class="cardViewGroup">
|
||||
<description class="CardViewHeading" hide="true" id="cvhOther">&other.heading;</description>
|
||||
<description class="CardViewText" hide="true" id="cvCustom1"/>
|
||||
<description class="CardViewText" hide="true" id="cvCustom2"/>
|
||||
<description class="CardViewText" hide="true" id="cvCustom3"/>
|
||||
<description class="CardViewText" hide="true" id="cvCustom4"/>
|
||||
<description class="CardViewText" hide="true" id="cvNotes"/>
|
||||
<description class="CardViewHeading" id="cvhOther">&other.heading;</description>
|
||||
<description class="CardViewText" id="cvCustom1"/>
|
||||
<description class="CardViewText" id="cvCustom2"/>
|
||||
<description class="CardViewText" id="cvCustom3"/>
|
||||
<description class="CardViewText" id="cvCustom4"/>
|
||||
<description class="CardViewText" id="cvNotes"/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="cvbDescription" class="cardViewGroup">
|
||||
<description class="CardViewHeading" id="cvhDescription">&description.heading;</description>
|
||||
<description class="CardViewText" id="cvDescription"/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="cvbAddresses" class="cardViewGroup">
|
||||
<description class="CardViewHeading" id="cvhAddresses">&addresses.heading;</description>
|
||||
<description class="CardViewText" id="cvAddresses"/>
|
||||
</vbox>
|
||||
</vbox>
|
||||
|
||||
@ -72,26 +89,29 @@ Rights Reserved.
|
||||
|
||||
<vbox flex="1" style="width:200px">
|
||||
<vbox id="cvbPhone" class="cardViewGroup">
|
||||
<description class="CardViewHeading" hide="true" id="cvhPhone">&phone.heading;</description>
|
||||
<description class="CardViewText" hide="true" id="cvPhWork"/>
|
||||
<description class="CardViewText" hide="true" id="cvPhHome"/>
|
||||
<description class="CardViewText" hide="true" id="cvPhFax"/>
|
||||
<description class="CardViewText" hide="true" id="cvPhCellular"/>
|
||||
<description class="CardViewText" hide="true" id="cvPhPager"/>
|
||||
<description class="CardViewHeading" id="cvhPhone">&phone.heading;</description>
|
||||
<description class="CardViewText" id="cvPhWork"/>
|
||||
<description class="CardViewText" id="cvPhHome"/>
|
||||
<description class="CardViewText" id="cvPhFax"/>
|
||||
<description class="CardViewText" id="cvPhCellular"/>
|
||||
<description class="CardViewText" id="cvPhPager"/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="cvbWork" class="cardViewGroup">
|
||||
<description class="CardViewHeading" hide="true" id="cvhWork">&work.heading;</description>
|
||||
<description class="CardViewText" hide="true" id="cvJobTitle"/>
|
||||
<description class="CardViewText" hide="true" id="cvDepartment"/>
|
||||
<description class="CardViewText" hide="true" id="cvCompany"/>
|
||||
<description class="CardViewText" hide="true" id="cvWorkAddress"/>
|
||||
<description class="CardViewText" hide="true" id="cvWorkAddress2"/>
|
||||
<description class="CardViewText" hide="true" id="cvWorkCityStZip"/>
|
||||
<description class="CardViewText" hide="true" id="cvWorkCountry"/>
|
||||
<description class="CardViewLink" hide="true" id="cvWorkWebPageBox">
|
||||
<html:p><html:a onclick="return openLink('cvWorkWebPage');" href="" id="cvWorkWebPage"/>
|
||||
</html:p></description>
|
||||
<description class="CardViewHeading" id="cvhWork">&work.heading;</description>
|
||||
<description class="CardViewText" id="cvJobTitle"/>
|
||||
<description class="CardViewText" id="cvDepartment"/>
|
||||
<description class="CardViewText" id="cvCompany"/>
|
||||
<description class="CardViewText" id="cvWorkAddress"/>
|
||||
<description class="CardViewText" id="cvWorkAddress2"/>
|
||||
<description class="CardViewText" id="cvWorkCityStZip"/>
|
||||
<description class="CardViewText" id="cvWorkCountry"/>
|
||||
<hbox id="cvbWorkMapItBox" autostretch="never">
|
||||
<button id="cvWorkMapIt" url="" label="&mapItButton.label;" onclick="MapIt('cvWorkMapIt');"/>
|
||||
</hbox>
|
||||
<description class="CardViewLink" id="cvWorkWebPageBox">
|
||||
<html:p><html:a onclick="return openLink('cvWorkWebPage');" href="" id="cvWorkWebPage"/></html:p>
|
||||
</description>
|
||||
</vbox>
|
||||
</vbox>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,9 @@ The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributors:
|
||||
Seth Spitzer <sspitzer@netscape.com>
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/addressPanes.css" type="text/css"?>
|
||||
@ -26,6 +29,10 @@ Rights Reserved.
|
||||
<overlay xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abDragDrop.js"/>
|
||||
|
||||
<!-- FIX ME - remove document.commandDispatcher.updateCommands() when tree selection calls this automatically -->
|
||||
<tree id="dirTree"
|
||||
class="abDirectory"
|
||||
@ -33,32 +40,25 @@ Rights Reserved.
|
||||
datasources="rdf:addressdirectory"
|
||||
containment="http://home.netscape.com/NC-rdf#child"
|
||||
onselect="DirPaneSelectionChange(); document.commandDispatcher.updateCommands('tree-select');"
|
||||
ondblclick="DirPaneDoubleClick();"
|
||||
onblur="goOnEvent(this,'blur')"
|
||||
allownegativeassertions="false"
|
||||
coalesceduplicatearcs="false"
|
||||
multiple="true"
|
||||
ondragover="return DragOverTree(event);"
|
||||
ondragdrop="return DropOnDirectoryTree(event);">
|
||||
|
||||
ondragover="nsDragAndDrop.dragOver(event, abDirTreeObserver);"
|
||||
ondragdrop="nsDragAndDrop.drop(event, abDirTreeObserver);">
|
||||
<treecolgroup>
|
||||
<treecol flex="1"/>
|
||||
</treecolgroup>
|
||||
<template>
|
||||
<rule>
|
||||
<treechildren>
|
||||
<treechildren flex="1">
|
||||
<treeitem uri="..." persist="sortColumn sortKey sortDirection">
|
||||
<treerow>
|
||||
<treecell indent="true" class="treecell-indent ab-directory-icon" label="rdf:http://home.netscape.com/NC-rdf#DirName"
|
||||
IsMailList="rdf:http://home.netscape.com/NC-rdf#IsMailList"/>
|
||||
IsMailList="rdf:http://home.netscape.com/NC-rdf#IsMailList"
|
||||
IsRemote="rdf:http://home.netscape.com/NC-rdf#IsRemote"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</rule>
|
||||
</template>
|
||||
|
||||
<treecolgroup>
|
||||
<treecol resource="http://home.netscape.com/NC-rdf#DirName" flex="1"/>
|
||||
</treecolgroup>
|
||||
|
||||
<treechildren id="dirTreeBody" flex="1">
|
||||
</treechildren>
|
||||
</tree>
|
||||
|
||||
</overlay>
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -35,195 +36,143 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function debugDump(msg)
|
||||
var abResultsPaneObserver = {
|
||||
onDragStart: function (aEvent, aXferData, aDragAction)
|
||||
{
|
||||
// uncomment for noise
|
||||
// dump(msg+"\n");
|
||||
}
|
||||
aXferData.data = new TransferData();
|
||||
var selectedRows = GetSelectedRows();
|
||||
var selectedAddresses = GetSelectedAddresses();
|
||||
|
||||
function GetDragService()
|
||||
aXferData.data.addDataForFlavour("moz/abcard", selectedRows);
|
||||
aXferData.data.addDataForFlavour("text/x-moz-address", selectedAddresses);
|
||||
},
|
||||
|
||||
onDrop: function (aEvent, aXferData, aDragSession)
|
||||
{
|
||||
var dragService = Components.classes["@mozilla.org/widget/dragservice;1"].getService();
|
||||
if (dragService)
|
||||
dragService = dragService.QueryInterface(Components.interfaces.nsIDragService);
|
||||
},
|
||||
|
||||
return dragService;
|
||||
}
|
||||
onDragExit: function (aEvent, aDragSession)
|
||||
{
|
||||
},
|
||||
|
||||
function DragOverTree(event)
|
||||
{
|
||||
var validFlavor = false;
|
||||
var dragSession = null;
|
||||
var retVal = true;
|
||||
onDragOver: function (aEvent, aFlavour, aDragSession)
|
||||
{
|
||||
},
|
||||
|
||||
var dragService = GetDragService();
|
||||
if ( !dragService ) return(false);
|
||||
|
||||
dragSession = dragService.getCurrentSession();
|
||||
if ( !dragSession ) return(false);
|
||||
|
||||
if ( dragSession.isDataFlavorSupported("text/nsabcard") ) validFlavor = true;
|
||||
//XXX other flavors here...
|
||||
|
||||
// touch the attribute on the rowgroup to trigger the repaint with the drop feedback.
|
||||
if ( validFlavor )
|
||||
getSupportedFlavours: function ()
|
||||
{
|
||||
//XXX this is really slow and likes to refresh N times per second.
|
||||
var treeItem = event.target.parentNode.parentNode;
|
||||
treeItem.setAttribute ( "dd-triggerrepaint", 0 );
|
||||
dragSession.canDrop = true;
|
||||
// necessary??
|
||||
retVal = false; // do not propagate message
|
||||
}
|
||||
return(retVal);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
function BeginDragResultTree(event)
|
||||
var abDirTreeObserver = {
|
||||
onDragStart: function (aEvent, aXferData, aDragAction)
|
||||
{
|
||||
debugDump("BeginDragResultTree\n");
|
||||
},
|
||||
|
||||
//XXX we rely on a capturer to already have determined which item the mouse was over
|
||||
//XXX and have set an attribute.
|
||||
|
||||
// if the click is on the tree proper, ignore it. We only care about clicks on items.
|
||||
onDrop: function (aEvent, aXferData, aDragSession)
|
||||
{
|
||||
var xferData = aXferData.data.split("\n");
|
||||
|
||||
if (event.target.localName != "treecell" &&
|
||||
event.target.localName != "treeitem")
|
||||
return false;
|
||||
// XXX do we still need this check, since we do it in onDragOver?
|
||||
if (aEvent.target.localName != "treecell") {
|
||||
return;
|
||||
}
|
||||
|
||||
var tree = resultsTree;
|
||||
if ( event.target == tree )
|
||||
return(true); // continue propagating the event
|
||||
// target is the <treecell>, and "id" is on the <treeitem> two levels above
|
||||
var treeItem = aEvent.target.parentNode.parentNode;
|
||||
if (!treeItem)
|
||||
return;
|
||||
|
||||
var dragStarted = false;
|
||||
var targetURI = treeItem.getAttribute("id");
|
||||
var directory = GetDirectoryFromURI(targetURI);
|
||||
|
||||
var dragService = GetDragService();
|
||||
if ( !dragService ) return(false);
|
||||
|
||||
var transArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
|
||||
if ( !transArray ) return(false);
|
||||
|
||||
var selArray = tree.selectedItems;
|
||||
var count = selArray.length;
|
||||
debugDump("selArray.length = " + count + "\n");
|
||||
for ( var i = 0; i < count; ++i )
|
||||
{
|
||||
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
|
||||
if ( !trans ) return(false);
|
||||
|
||||
var genTextData = Components.classes["@mozilla.org/supports-wstring;1"].createInstance(Components.interfaces.nsISupportsWString);
|
||||
if (!genTextData) return(false);
|
||||
|
||||
trans.addDataFlavor("text/nsabcard");
|
||||
var abView = GetAbView();
|
||||
|
||||
// get id (url)
|
||||
var id = selArray[i].getAttribute("id");
|
||||
genTextData.data = id;
|
||||
debugDump(" ID #" + i + " = " + id + "\n");
|
||||
var rows = xferData[0].split(",");
|
||||
var numrows = rows.length;
|
||||
var srcURI = GetAbViewURI();
|
||||
|
||||
trans.setTransferData ( "text/nsabcard", genTextData, id.length * 2 ); // doublebyte byte data
|
||||
if (srcURI == targetURI) {
|
||||
// should not be here
|
||||
return;
|
||||
}
|
||||
|
||||
// put it into the transferable as an |nsISupports|
|
||||
var genTrans = trans.QueryInterface(Components.interfaces.nsISupports);
|
||||
transArray.AppendElement(genTrans);
|
||||
}
|
||||
var result;
|
||||
var needToCopyCard = true;
|
||||
if (srcURI.length > targetURI.length) {
|
||||
result = srcURI.split(targetURI);
|
||||
if (result != srcURI) {
|
||||
// src directory is a mailing list on target directory, no need to copy card
|
||||
needToCopyCard = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = targetURI.split(srcURI);
|
||||
if (result != targetURI) {
|
||||
// target directory is a mailing list on src directory, no need to copy card
|
||||
needToCopyCard = false;
|
||||
}
|
||||
}
|
||||
|
||||
var nsIDragService = Components.interfaces.nsIDragService;
|
||||
dragService.invokeDragSession ( event.target, transArray, null, nsIDragService.DRAGDROP_ACTION_COPY +
|
||||
nsIDragService.DRAGDROP_ACTION_MOVE );
|
||||
dragStarted = true;
|
||||
// if we still think we have to copy the card,
|
||||
// check if srcURI and targetURI are mailing lists on same directory
|
||||
// if so, we don't have to copy the card
|
||||
if (needToCopyCard) {
|
||||
var targetParentURI = GetParentDirectoryFromMailingListURI(targetURI);
|
||||
if (targetParentURI && (targetParentURI == GetParentDirectoryFromMailingListURI(srcURI)))
|
||||
needToCopyCard = false;
|
||||
}
|
||||
|
||||
return(!dragStarted); // don't propagate the event if a drag has begun
|
||||
}
|
||||
for (var i=0;i<numrows;i++) {
|
||||
var card = abView.getCardFromRow(rows[i]);
|
||||
directory.dropCard(card, needToCopyCard);
|
||||
}
|
||||
var statusText = document.getElementById("statusText");
|
||||
// XXX get this approved, move it to a string bundle
|
||||
statusText.setAttribute("label", i + " Card(s) Copied");
|
||||
},
|
||||
|
||||
function DropOnDirectoryTree(event)
|
||||
onDragExit: function (aEvent, aDragSession)
|
||||
{
|
||||
debugDump("DropOnTree\n");
|
||||
},
|
||||
|
||||
if (event.target.localName != "treecell" &&
|
||||
event.target.localName != "treeitem")
|
||||
onDragOver: function (aEvent, aFlavour, aDragSession)
|
||||
{
|
||||
if (aEvent.target.localName != "treecell") {
|
||||
aDragSession.canDrop = false;
|
||||
return false;
|
||||
|
||||
var RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService().QueryInterface(Components.interfaces.nsIRDFService);
|
||||
if (!RDF) return(false);
|
||||
|
||||
var treeRoot = dirTree;
|
||||
if (!treeRoot) return(false);
|
||||
var treeDatabase = treeRoot.database;
|
||||
if (!treeDatabase) return(false);
|
||||
}
|
||||
|
||||
// target is the <treecell>, and "id" is on the <treeitem> two levels above
|
||||
var treeItem = event.target.parentNode.parentNode;
|
||||
if (!treeItem) return(false);
|
||||
var treeItem = aEvent.target.parentNode.parentNode;
|
||||
if (!treeItem)
|
||||
return false;
|
||||
|
||||
// drop action is always "on" not "before" or "after"
|
||||
// get drop hint attributes
|
||||
var dropBefore = treeItem.getAttribute("dd-droplocation");
|
||||
var dropOn = treeItem.getAttribute("dd-dropon");
|
||||
var targetURI = treeItem.getAttribute("id");
|
||||
var srcURI = GetAbViewURI();
|
||||
|
||||
var dropAction;
|
||||
if (dropOn == "true")
|
||||
dropAction = "on";
|
||||
else
|
||||
return(false);
|
||||
|
||||
var targetID = treeItem.getAttribute("id");
|
||||
if (!targetID) return(false);
|
||||
|
||||
debugDump("***targetID = " + targetID + "\n");
|
||||
|
||||
var dragService = GetDragService();
|
||||
if ( !dragService ) return(false);
|
||||
|
||||
var dragSession = dragService.getCurrentSession();
|
||||
if ( !dragSession ) return(false);
|
||||
|
||||
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
|
||||
if ( !trans ) return(false);
|
||||
trans.addDataFlavor("text/nsabcard");
|
||||
|
||||
for ( var i = 0; i < dragSession.numDropItems; ++i )
|
||||
{
|
||||
dragSession.getData ( trans, i );
|
||||
var dataObj = new Object();
|
||||
var bestFlavor = new Object();
|
||||
var len = new Object();
|
||||
trans.getAnyTransferData ( bestFlavor, dataObj, len );
|
||||
if ( dataObj ) dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsWString);
|
||||
if ( !dataObj ) continue;
|
||||
|
||||
// pull the URL out of the data object
|
||||
var sourceID = dataObj.data.substring(0, len.value);
|
||||
if (!sourceID) continue;
|
||||
|
||||
debugDump(" Node #" + i + ": drop '" + sourceID + "' " + dropAction + " '" + targetID + "'");
|
||||
debugDump("\n");
|
||||
|
||||
var sourceNode = RDF.GetResource(sourceID, true);
|
||||
if (!sourceNode)
|
||||
continue;
|
||||
|
||||
var targetNode = RDF.GetResource(targetID, true);
|
||||
if (!targetNode)
|
||||
continue;
|
||||
|
||||
// Prevent dropping of a node before, after, or on itself
|
||||
if (sourceNode == targetNode) continue;
|
||||
|
||||
if (sourceID.substring(0,targetID.length) != targetID)
|
||||
{
|
||||
var cardResource = rdf.GetResource(sourceID);
|
||||
var card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
if (card.isMailList == false)
|
||||
card.dropCardToDatabase(targetID);
|
||||
}
|
||||
// you can't drop a card onto the directory it comes from
|
||||
if (targetURI == srcURI) {
|
||||
aDragSession.canDrop = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return(false);
|
||||
// determine if we dragging from a mailing list on a directory x to the parent (directory x).
|
||||
// if so, don't allow the drop
|
||||
var result = srcURI.split(targetURI);
|
||||
if (result != srcURI) {
|
||||
aDragSession.canDrop = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
function DropOnResultTree(event)
|
||||
getSupportedFlavours: function ()
|
||||
{
|
||||
debugDump("DropOnResultTree\n");
|
||||
return false;
|
||||
var flavourSet = new FlavourSet();
|
||||
flavourSet.appendFlavour("moz/abcard");
|
||||
return flavourSet;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -30,8 +30,8 @@ Rights Reserved.
|
||||
title="&mailListWindow.title;"
|
||||
onload="OnLoadEditList()"
|
||||
ondialogaccept="return EditListOKButton();"
|
||||
ondragover="return DragOverTree(event);"
|
||||
ondragdrop="return DropOnAddressListTree(event);">
|
||||
ondragover="DragOverAddressListTree(event);"
|
||||
ondragdrop="DropOnAddressListTree(event);">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js"/>
|
||||
|
||||
|
@ -29,8 +29,9 @@ Rights Reserved.
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
|
||||
</stringbundleset>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abCommon.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abMailListDialog.js"/>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js"/>
|
||||
|
||||
<vbox id="editlist">
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -38,11 +39,17 @@ top.MAX_RECIPIENTS = 1;
|
||||
var inputElementType = "";
|
||||
|
||||
var mailList;
|
||||
var parentURI;
|
||||
var editList;
|
||||
var gParentURI;
|
||||
var gListCard;
|
||||
var gEditList;
|
||||
var gOkCallback = null;
|
||||
var hitReturnInList = false;
|
||||
var oldListName = "";
|
||||
var gAddressBookBundle;
|
||||
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
|
||||
var gDragService = Components.classes["@mozilla.org/widget/dragservice;1"].getService();
|
||||
gDragService = gDragService.QueryInterface(Components.interfaces.nsIDragService);
|
||||
|
||||
function handleKeyPress(element, event)
|
||||
{
|
||||
@ -67,9 +74,9 @@ function mailingListExists(listname)
|
||||
|
||||
function GetListValue(mailList, doAdd)
|
||||
{
|
||||
mailList.listName = document.getElementById('ListName').value;
|
||||
mailList.dirName = document.getElementById('ListName').value;
|
||||
|
||||
if (mailList.listName.length == 0)
|
||||
if (mailList.dirName.length == 0)
|
||||
{
|
||||
var alertText = gAddressBookBundle.getString("emptyListName");
|
||||
alert(alertText);
|
||||
@ -77,7 +84,7 @@ function GetListValue(mailList, doAdd)
|
||||
}
|
||||
else
|
||||
{
|
||||
var listname = mailList.listName;
|
||||
var listname = mailList.dirName;
|
||||
listname = listname.toLowerCase();
|
||||
oldListName = oldListName.toLowerCase();
|
||||
if (doAdd == true)
|
||||
@ -178,21 +185,35 @@ function MailListOKButton()
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // close the window
|
||||
}
|
||||
|
||||
function OnLoadMailList()
|
||||
function OnLoadNewMailList()
|
||||
{
|
||||
//XXX: gAddressBookBundle is set in 2 places because of different callers
|
||||
gAddressBookBundle = document.getElementById("bundle_addressBook");
|
||||
var selectedAB;
|
||||
var selectedAB = null;
|
||||
|
||||
if (window.arguments && window.arguments[0])
|
||||
{
|
||||
if ( window.arguments[0].selectedAB )
|
||||
selectedAB = window.arguments[0].selectedAB;
|
||||
else
|
||||
selectedAB = "moz-abmdbdirectory://abook.mab";
|
||||
var abURI = window.arguments[0].selectedAB;
|
||||
if (abURI) {
|
||||
var directory = GetDirectoryFromURI(abURI);
|
||||
if (directory.isMailList) {
|
||||
var parentURI = GetParentDirectoryFromMailingListURI(abURI);
|
||||
if (parentURI) {
|
||||
selectedAB = parentURI;
|
||||
}
|
||||
}
|
||||
else {
|
||||
selectedAB = abURI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectedAB)
|
||||
selectedAB = kPersonalAddressbookURI;
|
||||
|
||||
// set popup with address book names
|
||||
var abPopup = document.getElementById('abPopup');
|
||||
@ -220,6 +241,7 @@ function OnLoadMailList()
|
||||
var listName = document.getElementById('ListName');
|
||||
if ( listName )
|
||||
listName.focus();
|
||||
|
||||
moveToAlertPosition();
|
||||
}
|
||||
|
||||
@ -230,10 +252,21 @@ function EditListOKButton()
|
||||
hitReturnInList = false;
|
||||
return false;
|
||||
}
|
||||
//Add mailing list to database
|
||||
if (GetListValue(editList, false))
|
||||
//edit mailing list in database
|
||||
if (GetListValue(gEditList, false))
|
||||
{
|
||||
editList.editMailListToDatabase(parentURI);
|
||||
if (gListCard) {
|
||||
// modify the list card (for the results pane) from the mailing list
|
||||
gListCard.displayName = gEditList.dirName;
|
||||
gListCard.lastName = gEditList.dirName;
|
||||
gListCard.nickName = gEditList.listNickName;
|
||||
gListCard.notes = gEditList.description;
|
||||
}
|
||||
|
||||
gEditList.editMailListToDatabase(gParentURI, gListCard);
|
||||
|
||||
if (gOkCallback)
|
||||
gOkCallback();
|
||||
return true; // close the window
|
||||
}
|
||||
else
|
||||
@ -245,22 +278,21 @@ function OnLoadEditList()
|
||||
//XXX: gAddressBookBundle is set in 2 places because of different callers
|
||||
gAddressBookBundle = document.getElementById("bundle_addressBook");
|
||||
|
||||
parentURI = window.arguments[0].abURI;
|
||||
gParentURI = window.arguments[0].abURI;
|
||||
gListCard = window.arguments[0].abCard;
|
||||
var listUri = window.arguments[0].listURI;
|
||||
gOkCallback = window.arguments[0].okCallback;
|
||||
|
||||
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
|
||||
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
editList = rdf.GetResource(listUri);
|
||||
editList = editList.QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
gEditList = GetDirectoryFromURI(listUri);
|
||||
|
||||
document.getElementById('ListName').value = editList.listName;
|
||||
document.getElementById('ListNickName').value = editList.listNickName;
|
||||
document.getElementById('ListDescription').value = editList.description;
|
||||
oldListName = editList.listName;
|
||||
document.getElementById('ListName').value = gEditList.dirName;
|
||||
document.getElementById('ListNickName').value = gEditList.listNickName;
|
||||
document.getElementById('ListDescription').value = gEditList.description;
|
||||
oldListName = gEditList.dirName;
|
||||
|
||||
if (editList.addressLists)
|
||||
if (gEditList.addressLists)
|
||||
{
|
||||
var total = editList.addressLists.Count();
|
||||
var total = gEditList.addressLists.Count();
|
||||
if (total)
|
||||
{
|
||||
var treeChildren = document.getElementById('addressList');
|
||||
@ -270,11 +302,11 @@ function OnLoadEditList()
|
||||
top.MAX_RECIPIENTS = 0;
|
||||
for ( var i = 0; i < total; i++ )
|
||||
{
|
||||
var card = editList.addressLists.GetElementAt(i);
|
||||
var card = gEditList.addressLists.GetElementAt(i);
|
||||
card = card.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
var address;
|
||||
if (card.name.length)
|
||||
address = card.name + " <" + card.primaryEmail + ">";
|
||||
if (card.displayName)
|
||||
address = card.displayName + " <" + card.primaryEmail + ">";
|
||||
else
|
||||
address = card.primaryEmail;
|
||||
SetInputValue(address, newTreeChildrenNode, templateNode);
|
||||
@ -290,6 +322,7 @@ function OnLoadEditList()
|
||||
var listName = document.getElementById('ListName');
|
||||
if ( listName )
|
||||
listName.focus();
|
||||
|
||||
moveToAlertPosition();
|
||||
}
|
||||
|
||||
@ -546,7 +579,7 @@ function awFinishCopyNodes()
|
||||
|
||||
function awTabFromRecipient(element, event)
|
||||
{
|
||||
//If we are le last element in the tree, we don't want to create a new row.
|
||||
//If we are the last element in the tree, we don't want to create a new row.
|
||||
if (element == awGetInputElement(top.MAX_RECIPIENTS))
|
||||
top.doNotCreateANewRow = true;
|
||||
}
|
||||
@ -556,22 +589,15 @@ function awGetNumberOfRecipients()
|
||||
return top.MAX_RECIPIENTS;
|
||||
}
|
||||
|
||||
function DragOverTree(event)
|
||||
function DragOverAddressListTree(event)
|
||||
{
|
||||
var validFlavor = false;
|
||||
var dragSession = null;
|
||||
var retVal = true;
|
||||
var dragSession = gDragService.getCurrentSession();
|
||||
|
||||
var dragService = Components.classes["@mozilla.org/widget/dragservice;1"].getService();
|
||||
if (dragService)
|
||||
dragService = dragService.QueryInterface(Components.interfaces.nsIDragService);
|
||||
if (!dragService) return(false);
|
||||
|
||||
dragSession = dragService.getCurrentSession();
|
||||
if (!dragSession) return(false);
|
||||
|
||||
if (dragSession.isDataFlavorSupported("text/nsabcard")) validFlavor = true;
|
||||
//XXX other flavors here...
|
||||
// XXX add support for other flavors here
|
||||
if (dragSession.isDataFlavorSupported("text/x-moz-address")) {
|
||||
validFlavor = true;
|
||||
}
|
||||
|
||||
// touch the attribute on the rowgroup to trigger the repaint with the drop feedback.
|
||||
if (validFlavor)
|
||||
@ -581,30 +607,21 @@ function DragOverTree(event)
|
||||
if (rowGroup)
|
||||
rowGroup.setAttribute ( "dd-triggerrepaint", 0 );
|
||||
dragSession.canDrop = true;
|
||||
// necessary??
|
||||
retVal = false; // do not propagate message
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
function DropOnAddressListTree(event)
|
||||
{
|
||||
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
|
||||
if (rdf)
|
||||
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
if (!rdf) return(false);
|
||||
var dragSession = gDragService.getCurrentSession();
|
||||
var trans;
|
||||
|
||||
var dragService = Components.classes["@mozilla.org/widget/dragservice;1"].getService();
|
||||
if (dragService)
|
||||
dragService = dragService.QueryInterface(Components.interfaces.nsIDragService);
|
||||
if (!dragService) return(false);
|
||||
|
||||
var dragSession = dragService.getCurrentSession();
|
||||
if ( !dragSession ) return(false);
|
||||
|
||||
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
|
||||
if ( !trans ) return(false);
|
||||
trans.addDataFlavor("text/nsabcard");
|
||||
try {
|
||||
trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
|
||||
trans.addDataFlavor("text/x-moz-address");
|
||||
}
|
||||
catch (ex) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( var i = 0; i < dragSession.numDropItems; ++i )
|
||||
{
|
||||
@ -617,32 +634,17 @@ function DropOnAddressListTree(event)
|
||||
if ( !dataObj ) continue;
|
||||
|
||||
// pull the URL out of the data object
|
||||
var sourceID = dataObj.data.substring(0, len.value);
|
||||
if (!sourceID) continue;
|
||||
|
||||
var cardResource = rdf.GetResource(sourceID);
|
||||
var card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
|
||||
if (card.isMailList)
|
||||
DropListAddress(card.name);
|
||||
else
|
||||
{
|
||||
var address;
|
||||
if (card.name.length)
|
||||
address = card.name + " <" + card.primaryEmail + ">";
|
||||
else
|
||||
address = card.primaryEmail;
|
||||
DropListAddress(address);
|
||||
}
|
||||
var address = dataObj.data.substring(0, len.value);
|
||||
if (!address)
|
||||
continue;
|
||||
|
||||
DropListAddress(event.target, address);
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
function DropListAddress(address)
|
||||
function DropListAddress(target, address)
|
||||
{
|
||||
awClickEmptySpace(true); //that will automatically set the focus on a new available row, and make sure is visible
|
||||
awClickEmptySpace(target, true); //that will automatically set the focus on a new available row, and make sure is visible
|
||||
if (top.MAX_RECIPIENTS == 0)
|
||||
top.MAX_RECIPIENTS = 1;
|
||||
var lastInput = awGetInputElement(top.MAX_RECIPIENTS);
|
||||
|
@ -21,7 +21,6 @@ Rights Reserved.
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/dialogs.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abListOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abMailListDialog.dtd">
|
||||
@ -31,16 +30,17 @@ Rights Reserved.
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
title="&mailListWindow.title;"
|
||||
ondialogaccept="return MailListOKButton();"
|
||||
onload="OnLoadMailList()"
|
||||
ondragover="return DragOverTree(event);"
|
||||
ondragdrop="return DropOnAddressListTree(event);">
|
||||
onload="OnLoadNewMailList()"
|
||||
ondragover="DragOverAddressListTree(event);"
|
||||
ondragdrop="DropOnAddressListTree(event);">
|
||||
|
||||
<stringbundleset id="stringbundleset"/>
|
||||
|
||||
<hbox align="center" valign="center">
|
||||
<label control="abPopup" value="&addToAddressBook.label;" accesskey="&addToAddressBook.accesskey;"/>
|
||||
<menulist id="abPopup">
|
||||
<menupopup id="abPopup-menupopup" ref="moz-abdirectory://" datasources="rdf:addressdirectory">
|
||||
<menupopup id="abPopup-menupopup" ref="moz-abdirectory://"
|
||||
datasources="rdf:addressdirectory">
|
||||
<template>
|
||||
<rule nc:IsMailList="false">
|
||||
<menuitem uri="..."
|
||||
|
@ -42,7 +42,8 @@ Rights Reserved.
|
||||
|
||||
<label control="abPopup" value="&chooseAddressBook.label;"/>
|
||||
<menulist id="abPopup">
|
||||
<menupopup id="abPopup-menupopup" ref="moz-abdirectory://" datasources="rdf:addressdirectory">
|
||||
<menupopup id="abPopup-menupopup" ref="moz-abdirectory://"
|
||||
datasources="rdf:addressdirectory">
|
||||
<template>
|
||||
<rule nc:IsMailList="false">
|
||||
<menuitem uri="..."
|
||||
|
@ -52,7 +52,7 @@
|
||||
<outliner id="abResultsOutliner" flex="1" enableColumnDrag="true" class="plain"
|
||||
onclick="AbResultsPaneOnClick(event);">
|
||||
|
||||
<outlinercols>
|
||||
<outlinercols id="abResultsOutlinerCols">
|
||||
<!-- these column ids must match up to the mork column names, except for GeneratedName, see nsIAddrDatabase.idl -->
|
||||
<outlinercol id="GeneratedName" class="sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&GeneratedName.label;" primary="true"/>
|
||||
|
@ -1,87 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Alexis Ledoux <alexis.ledoux@ireland.sun.com>
|
||||
Seth Spitzer <sspitzer@netscape.com>
|
||||
-->
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abResultsTreeOverlay.dtd">
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/addressPanes.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
|
||||
|
||||
<overlay xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abDragDrop.js"/>
|
||||
<!-- FIX ME - remove document.commandDispatcher.updateCommands() when tree selection calls this automatically -->
|
||||
<tree id="resultsTree"
|
||||
class="abResults"
|
||||
datasources="rdf:addressdirectory rdf:addresscard"
|
||||
onselect="ResultsPaneSelectionChange(); document.commandDispatcher.updateCommands('tree-select');"
|
||||
onblur="goOnEvent(this,'blur')"
|
||||
onclick="clickResultsTree(event);"
|
||||
containment="http://home.netscape.com/NC-rdf#CardChild"
|
||||
allownegativeassertions="false"
|
||||
coalesceduplicatearcs="false"
|
||||
ondragover="return DragOverTree(event);"
|
||||
ondraggesture="return BeginDragResultTree(event);"
|
||||
ondragdrop="return DropOnResultTree(event);"
|
||||
multiple="true">
|
||||
|
||||
<template>
|
||||
<rule>
|
||||
<treechildren flex="1">
|
||||
<treeitem uri="...">
|
||||
<treerow id="AbRows">
|
||||
<treecell colid="NameColumn" class="treecell-indent ab-results-icon" label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
<treecell colid="EmailColumn" label="rdf:http://home.netscape.com/NC-rdf#PrimaryEmail"/>
|
||||
<treecell colid="WorkPhoneColumn" label="rdf:http://home.netscape.com/NC-rdf#WorkPhone"/>
|
||||
<treecell colid="OrganizationColumn" label="rdf:http://home.netscape.com/NC-rdf#Company"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</rule>
|
||||
</template>
|
||||
|
||||
<treecolgroup id="theColumns">
|
||||
<treecol persist="hidden width" flex="2" id="NameColumn" resource="http://home.netscape.com/NC-rdf#Name"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol persist="hidden width" flex="3" id="EmailColumn" resource="http://home.netscape.com/NC-rdf#PrimaryEmail"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol persist="hidden width" flex="2" id="WorkPhoneColumn" resource="http://home.netscape.com/NC-rdf#WorkPhone"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol persist="hidden width" flex="2" id="OrganizationColumn" resource="http://home.netscape.com/NC-rdf#Company"/>
|
||||
</treecolgroup>
|
||||
|
||||
<treehead>
|
||||
<treerow id="headRow">
|
||||
<treecell id="NameColumnHeader" label="&nameColumn.label;" class="sortDirectionIndicator treecell-header treecell-inset-header" onclick="return SortResultPane('NameColumn', 'http://home.netscape.com/NC-rdf#Name');"/>
|
||||
<treecell id="EmailColumnHeader" label="&emailColumn.label;" class="sortDirectionIndicator treecell-header treecell-inset-header" onclick="return SortResultPane('EmailColumn', 'http://home.netscape.com/NC-rdf#PrimaryEmail');"/>
|
||||
<treecell id="WorkPhoneColumnHeader" label="&workPhoneColumn.label;" class="sortDirectionIndicator treecell-header treecell-inset-header" onclick="return SortResultPane('WorkPhoneColumn', 'http://home.netscape.com/NC-rdf#WorkPhone');"/>
|
||||
<treecell id="OrganizationColumnHeader" label="&organizationColumn.label;" class="sortDirectionIndicator treecell-header treecell-inset-header" onclick="return SortResultPane('OrganizationColumn', 'http://home.netscape.com/NC-rdf#Company');"/>
|
||||
</treerow>
|
||||
</treehead>
|
||||
|
||||
</tree>
|
||||
|
||||
</overlay>
|
@ -16,16 +16,17 @@
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Paul Hangas <hangas@netscape.com>
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
* Paul Hangas <hangas@netscape.com>
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*/
|
||||
|
||||
var addressbook = 0;
|
||||
var composeWindow = 0;
|
||||
var msgCompFields = 0;
|
||||
var editCardCallback = 0;
|
||||
var gDialogResultsPaneSelectionChanged = 0;
|
||||
|
||||
var gAddressBookBundle;
|
||||
|
||||
@ -34,6 +35,23 @@ var prefixTo;
|
||||
var prefixCc;
|
||||
var prefixBcc;
|
||||
|
||||
var gDragService = Components.classes["@mozilla.org/widget/dragservice;1"].getService();
|
||||
gDragService = gDragService.QueryInterface(Components.interfaces.nsIDragService);
|
||||
|
||||
var gSelectAddressesAbViewListener = {
|
||||
onSelectionChanged: function() {
|
||||
ResultsPaneSelectionChanged();
|
||||
},
|
||||
onCountChanged: function(total) {
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
|
||||
function GetAbViewListener()
|
||||
{
|
||||
return gSelectAddressesAbViewListener;
|
||||
}
|
||||
|
||||
function OnLoadSelectAddress()
|
||||
{
|
||||
gAddressBookBundle = document.getElementById("bundle_addressBook");
|
||||
@ -43,14 +61,13 @@ function OnLoadSelectAddress()
|
||||
|
||||
InitCommonJS();
|
||||
|
||||
UpgradeAddressBookResultsPaneUI("mailnews.ui.select_addresses_results.version");
|
||||
|
||||
var toAddress="", ccAddress="", bccAddress="";
|
||||
|
||||
doSetOKCancel(SelectAddressOKButton, 0);
|
||||
|
||||
top.addressbook = Components.classes["@mozilla.org/addressbook;1"].createInstance();
|
||||
top.addressbook = top.addressbook.QueryInterface(Components.interfaces.nsIAddressBook);
|
||||
|
||||
top.gDialogResultsPaneSelectionChanged = DialogResultsPaneSelectionChanged;
|
||||
top.addressbook = Components.classes["@mozilla.org/addressbook;1"].createInstance(Components.interfaces.nsIAddressBook);
|
||||
|
||||
// look in arguments[0] for parameters
|
||||
if (window.arguments && window.arguments[0])
|
||||
@ -67,9 +84,6 @@ function OnLoadSelectAddress()
|
||||
if ( window.arguments[0].bccAddress )
|
||||
bccAddress = window.arguments[0].bccAddress;
|
||||
|
||||
dump("onload top.composeWindow: " + top.composeWindow + "\n");
|
||||
dump("onload toAddress: " + toAddress + "\n");
|
||||
|
||||
// put the addresses into the bucket
|
||||
AddAddressFromComposeWindow(toAddress, prefixTo);
|
||||
AddAddressFromComposeWindow(ccAddress, prefixCc);
|
||||
@ -78,10 +92,14 @@ function OnLoadSelectAddress()
|
||||
|
||||
SelectFirstAddressBook();
|
||||
|
||||
DialogResultsPaneSelectionChanged();
|
||||
DialogBucketPaneSelectionChanged();
|
||||
}
|
||||
|
||||
function OnUnloadSelectAddress()
|
||||
{
|
||||
CloseAbView();
|
||||
}
|
||||
|
||||
function AddAddressFromComposeWindow(addresses, prefix)
|
||||
{
|
||||
if ( addresses )
|
||||
@ -99,7 +117,6 @@ function AddAddressFromComposeWindow(addresses, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function SelectAddressOKButton()
|
||||
{
|
||||
var body = document.getElementById('bucketBody');
|
||||
@ -179,30 +196,22 @@ function SelectAddressBccButton()
|
||||
|
||||
function AddSelectedAddressesIntoBucket(prefix)
|
||||
{
|
||||
var item, uri, rdf, cardResource, card, address;
|
||||
var email ="";
|
||||
rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
|
||||
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
var cards = GetSelectedAbCards();
|
||||
var count = cards.length;
|
||||
|
||||
if ( resultsTree && resultsTree.selectedItems && resultsTree.selectedItems.length )
|
||||
{
|
||||
for ( item = 0; item < resultsTree.selectedItems.length; item++ )
|
||||
{
|
||||
uri = resultsTree.selectedItems[item].getAttribute('id');
|
||||
cardResource = rdf.GetResource(uri);
|
||||
card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
if (card.isMailList)
|
||||
{
|
||||
address = prefix + "\"" + card.name + "\" <" + card.name + ">";
|
||||
email = card.name;
|
||||
for (var i = 0; i < count; i++) {
|
||||
AddCardIntoBucket(prefix, cards[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
address = prefix + "\"" + card.name + "\" <" + card.primaryEmail + ">";
|
||||
email = card.primaryEmail;
|
||||
}
|
||||
AddAddressIntoBucket(address,email);
|
||||
|
||||
function AddCardIntoBucket(prefix, card)
|
||||
{
|
||||
var address = prefix + GenerateAddressFromCard(card);
|
||||
if (card.isMailList) {
|
||||
AddAddressIntoBucket(address, card.displayName);
|
||||
}
|
||||
else {
|
||||
AddAddressIntoBucket(address, card.primaryEmail);
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,8 +245,8 @@ function RemoveSelectedFromBucket()
|
||||
}
|
||||
}
|
||||
|
||||
/* Function: DialogResultsPaneSelectionChanged()
|
||||
* Callers : OnLoadSelectAddress(), abCommon.js:ResultsPaneSelectionChange()
|
||||
/* Function: ResultsPaneSelectionChanged()
|
||||
* Callers : OnLoadSelectAddress(), abCommon.js:ResultsPaneSelectionChanged()
|
||||
* -------------------------------------------------------------------------
|
||||
* This function is used to grab the selection state of the results tree to maintain
|
||||
* the appropriate enabled/disabled states of the "Edit", "To:", "CC:", and "Bcc:" buttons.
|
||||
@ -245,17 +254,21 @@ function RemoveSelectedFromBucket()
|
||||
* Otherwise, if nothing is selected, "disabled" is set to true.
|
||||
*/
|
||||
|
||||
function DialogResultsPaneSelectionChanged()
|
||||
{
|
||||
var resultsTree = document.getElementById("resultsTree");
|
||||
function ResultsPaneSelectionChanged()
|
||||
{;
|
||||
var editButton = document.getElementById("edit");
|
||||
var toButton = document.getElementById("toButton");
|
||||
var ccButton = document.getElementById("ccButton");
|
||||
var bccButton = document.getElementById("bccButton");
|
||||
|
||||
if (editButton && toButton && ccButton && bccButton && resultsTree && resultsTree.selectedItems && resultsTree.selectedItems.length)
|
||||
var numSelected = GetNumSelectedCards();
|
||||
if (numSelected > 0)
|
||||
{
|
||||
if (numSelected == 1)
|
||||
editButton.removeAttribute("disabled");
|
||||
else
|
||||
editButton.setAttribute("disabled", "true");
|
||||
|
||||
toButton.removeAttribute("disabled");
|
||||
ccButton.removeAttribute("disabled");
|
||||
bccButton.removeAttribute("disabled");
|
||||
@ -289,4 +302,59 @@ function DialogBucketPaneSelectionChanged()
|
||||
removeButton.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
function AbResultsPaneDoubleClick(card)
|
||||
{
|
||||
AddCardIntoBucket(prefixTo, card);
|
||||
}
|
||||
|
||||
function OnClickedCard(card)
|
||||
{
|
||||
// in the select address dialog, do nothing on click
|
||||
}
|
||||
|
||||
function UpdateCardView()
|
||||
{
|
||||
// in the select address dialog, do nothing
|
||||
}
|
||||
|
||||
function DragOverBucketPane(event)
|
||||
{
|
||||
var dragSession = gDragService.getCurrentSession();
|
||||
|
||||
if (dragSession.isDataFlavorSupported("text/x-moz-address"))
|
||||
dragSession.canDrop = true;
|
||||
}
|
||||
|
||||
function DropOnBucketPane(event)
|
||||
{
|
||||
var dragSession = gDragService.getCurrentSession();
|
||||
var trans;
|
||||
|
||||
try {
|
||||
trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
|
||||
trans.addDataFlavor("text/x-moz-address");
|
||||
}
|
||||
catch (ex) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( var i = 0; i < dragSession.numDropItems; ++i )
|
||||
{
|
||||
dragSession.getData ( trans, i );
|
||||
var dataObj = new Object();
|
||||
var bestFlavor = new Object();
|
||||
var len = new Object();
|
||||
trans.getAnyTransferData ( bestFlavor, dataObj, len );
|
||||
if ( dataObj )
|
||||
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsWString);
|
||||
if ( !dataObj )
|
||||
continue;
|
||||
|
||||
// pull the address out of the data object
|
||||
var address = dataObj.data.substring(0, len.value);
|
||||
if (!address)
|
||||
continue;
|
||||
|
||||
AddAddressIntoBucket(prefixTo + address, address);
|
||||
}
|
||||
}
|
||||
|
@ -17,24 +17,34 @@ The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Seth Spitzer <sspitzer@netscape.com>
|
||||
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/selectAddressesDialog.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abDirTreeOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abResultsTreeOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abResultsPaneOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abSelectAddressesDialog.dtd">
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % abSelectAddressesDialogDTD SYSTEM "chrome://messenger/locale/addressbook/abSelectAddressesDialog.dtd" >
|
||||
%abSelectAddressesDialogDTD;
|
||||
<!ENTITY % abResultsPaneOverlayDTD SYSTEM "chrome://messenger/locale/addressbook/abResultsPaneOverlay.dtd" >
|
||||
%abResultsPaneOverlayDTD;
|
||||
]>
|
||||
|
||||
<window xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&selectAddressWindow.title;"
|
||||
class="dialog"
|
||||
width="680" height="480"
|
||||
onload="OnLoadSelectAddress()">
|
||||
onload="OnLoadSelectAddress()"
|
||||
onunload="OnUnloadSelectAddress()">
|
||||
|
||||
<stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
|
||||
<stringbundle id="bundle_composeMsgs" src="chrome://messenger/locale/messengercompose/composeMsgs.properties"/>
|
||||
@ -47,9 +57,9 @@ Rights Reserved.
|
||||
<keyset id="dialogKeys"/>
|
||||
|
||||
<!-- Main box, 3 pane and majority of buttons -->
|
||||
<hbox flex="100%">
|
||||
<hbox flex="1">
|
||||
<!-- 3 Pane box -->
|
||||
<hbox id="3PaneBox" flex="100%">
|
||||
<hbox id="3PaneBox" flex="1">
|
||||
|
||||
<!-- dir tree -->
|
||||
<hbox id="dirTreeBox">
|
||||
@ -59,23 +69,23 @@ Rights Reserved.
|
||||
<splitter id="vertical-splitter" collapse="before" persist="state"/>
|
||||
|
||||
<!-- Box that holds results pane, (to,cc,bcc buttons), and address bucket -->
|
||||
<vbox id="results-bucket-tree-box" flex="100%">
|
||||
<vbox id="results-bucket-tree-box" flex="1">
|
||||
<!-- Box that holds results pane and (to,cc,bcc buttons) -->
|
||||
<vbox flex="100%">
|
||||
<!-- results tree -->
|
||||
<vbox id="resultsTreeBox" flex="100%">
|
||||
<tree id="resultsTree" flex="1"/>
|
||||
<vbox flex="1">
|
||||
<!-- results pane -->
|
||||
<vbox id="results_box" flex="1">
|
||||
<outliner id="abResultsOutliner" flex="1" persist="height" />
|
||||
</vbox>
|
||||
|
||||
<!-- Box that holds (to,cc,bcc buttons) -->
|
||||
<hbox id="addToBucketButtonBox">
|
||||
<spacer flex="50%"/>
|
||||
<spacer flex="1"/>
|
||||
<button id="toButton" label="&toButton.label;" oncommand="SelectAddressToButton()"/>
|
||||
<spacer class="middle-button-spacer"/>
|
||||
<button id="ccButton" label="&ccButton.label;" oncommand="SelectAddressCcButton()"/>
|
||||
<spacer class="middle-button-spacer"/>
|
||||
<button id="bccButton" label="&bccButton.label;" oncommand="SelectAddressBccButton()"/>
|
||||
<spacer flex="50%"/>
|
||||
<spacer flex="1"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
@ -83,7 +93,10 @@ Rights Reserved.
|
||||
|
||||
<!-- Address bucket -->
|
||||
<vbox id="bucketBox">
|
||||
<tree id="addressBucket" flex="1" multiple="true" onselect="top.DialogBucketPaneSelectionChanged();">
|
||||
<tree id="addressBucket" flex="1" multiple="true"
|
||||
ondragover="DragOverBucketPane(event);"
|
||||
ondragdrop="DropOnBucketPane(event);"
|
||||
onselect="DialogBucketPaneSelectionChanged();">
|
||||
<treecolgroup>
|
||||
<treecol flex="1"/>
|
||||
</treecolgroup>
|
||||
@ -96,17 +109,17 @@ Rights Reserved.
|
||||
|
||||
<!-- Box with buttons on right edge of window -->
|
||||
<vbox id="rightColumnButtonBox">
|
||||
<vbox flex="50%">
|
||||
<vbox flex="1">
|
||||
<spacer class="third-column-spacer"/>
|
||||
<button id="new" label="&newButton.label;" tooltiptext="&addressPickerNewButton.tooltip;" oncommand="AbNewCard('dirTree')"/>
|
||||
<spacer class="third-column-spacer"/>
|
||||
<button id="edit" label="&editButton.label;" tooltiptext="&addressPickerEditButton.tooltip;" oncommand="AbEditCard()"/>
|
||||
<spacer flex="100%"/>
|
||||
<button id="edit" label="&editButton.label;" tooltiptext="&addressPickerEditButton.tooltip;" oncommand="AbEditSelectedCard()"/>
|
||||
<spacer flex="1"/>
|
||||
</vbox>
|
||||
<vbox flex="50%">
|
||||
<spacer flex="50%"/>
|
||||
<vbox flex="1">
|
||||
<spacer flex="1"/>
|
||||
<button id="remove" label="&removeButton.label;" class="dialog" oncommand="RemoveSelectedFromBucket()"/>
|
||||
<spacer flex="50%"/>
|
||||
<spacer flex="1"/>
|
||||
</vbox>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
@ -18,82 +18,69 @@
|
||||
- Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
- Rights Reserved.
|
||||
|
||||
Original Author:
|
||||
Blake Ross <blakeross@telocity.com>
|
||||
Contributor(s):
|
||||
- Blake Ross <blakeross@telocity.com> (Original Author)
|
||||
Seth Spitzer <sspitzer@netscape.com>
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/sidebarPanel.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/addressPanes.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/abResultsPane.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abDirTreeOverlay.xul"?>
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abResultsTreeOverlay.dtd" >
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abResultsPaneOverlay.dtd" >
|
||||
<page id="addressbook-panel"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="InitCommonJS(); abPanelStartup();"
|
||||
onload="AbPanelLoad();"
|
||||
onunload="AbPanelUnload();"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/addressbook.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abCommon.js"/>
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
function abPanelStartup() {
|
||||
var abList = document.getElementById('addressbookList');
|
||||
ChangeDirectoryByDOMNode(abList.selectedItem);
|
||||
// XXXbar this should definitely not be necessary
|
||||
// for some reason, the menulist is getting its label set to
|
||||
// the label of its first item automatically even though its
|
||||
// selectedItem is correct; this is not done in its constructor.
|
||||
abList.label = abList.selectedItem.getAttribute('label');
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abResultsPane.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/addressbook-panel.js"/>
|
||||
|
||||
<popup id="composeMail">
|
||||
<menuitem label="&composeEmail.label;" accesskey="&composeEmail.accesskey;" oncommand="AbNewMessage();" default="true"/>
|
||||
<menuitem label="&deleteAddrBookCard.label;" accesskey="&deleteAddrBookCard.accesskey;" oncommand="AbDelete();"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&newAddrBookCard.label;" accesskey="&newAddrBookCard.accesskey;" oncommand="AbNewCard('addressbookList');"/>
|
||||
<menuitem label="&newAddrBookMailingList.label;" accesskey="&newAddrBookMailingList.accesskey;" oncommand="AbNewList('addressbookList');"/>
|
||||
<menuitem label="&newAddrBookCard.label;" accesskey="&newAddrBookCard.accesskey;" oncommand="AbPanelNewCard();"/>
|
||||
<menuitem label="&newAddrBookMailingList.label;" accesskey="&newAddrBookMailingList.accesskey;" oncommand="AbPanelNewList();"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&addrBookCardProperties.label;" accesskey="&addrBookCardProperties.accesskey;" oncommand="AbEditCard();"/>
|
||||
<menuitem label="&addrBookCardProperties.label;" accesskey="&addrBookCardProperties.accesskey;" oncommand="AbEditSelectedCard();"/>
|
||||
</popup>
|
||||
<vbox id="results_box" flex="1">
|
||||
<hbox id="panel-bar" class="toolbar">
|
||||
<menulist id="addressbookList" oncommand="ChangeDirectoryByDOMNode(event.target);" flex="1">
|
||||
<menupopup id="addressbookPopup" datasources="rdf:addressdirectory" ref="moz-abdirectory://">
|
||||
<menulist id="addressbookList" persist="selectedAB" oncommand="AbPanelOnChange(event)" flex="1">
|
||||
<menupopup id="addressbookList-menupopup"
|
||||
datasources="rdf:addressdirectory"
|
||||
ref="moz-abdirectory://">
|
||||
<template>
|
||||
<rule nc:IsMailList="false">
|
||||
<menuitem label="rdf:http://home.netscape.com/NC-rdf#DirName" uri="..." persist="selected"/>
|
||||
<menuitem uri="..."
|
||||
label="rdf:http://home.netscape.com/NC-rdf#DirName"
|
||||
value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
|
||||
</rule>
|
||||
</template>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</hbox>
|
||||
<tree id="resultsTree" flex="1" datasources="rdf:addressdirectory rdf:addresscard"
|
||||
style="height:0px" ondblclick="if (event.button == 0) AbNewMessage();" class="abResults"
|
||||
containment="http://home.netscape.com/NC-rdf#CardChild"
|
||||
allownegativeassertions="false" context="composeMail"
|
||||
coalesceduplicatearcs="false"
|
||||
onselect="window.updateCommands('tree-select'); window.updateCommands('select');">
|
||||
<template>
|
||||
<rule>
|
||||
<treechildren flex="1">
|
||||
<treeitem uri="...">
|
||||
<treerow id="AbRows">
|
||||
<treecell class="treecell-iconic cardicon" label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</rule>
|
||||
</template>
|
||||
<treecolgroup id="theColumns">
|
||||
<treecol persist="hidden width" flex="2" id="NameColumn" resource="http://home.netscape.com/NC-rdf#Name"/>
|
||||
</treecolgroup>
|
||||
<treehead>
|
||||
<treerow id="headRow">
|
||||
<treecell id="NameColumnHeader" label="&nameColumn.label;" class="sortDirectionIndicator treecell-header treecell-inset-header" onclick="return SortResultPane('NameColumn', 'http://home.netscape.com/NC-rdf#Name');"/>
|
||||
</treerow>
|
||||
</treehead>
|
||||
</tree>
|
||||
|
||||
<outliner id="abResultsOutliner" flex="1" context="composeMail" onclick="AbResultsPaneOnClick(event);" class="plain">
|
||||
<outlinercols>
|
||||
<!-- these column ids must match up to the mork column names, see nsIAddrDatabase.idl -->
|
||||
<outlinercol id="GeneratedName" class="sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&GeneratedName.label;" primary="true"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="PrimaryEmail" class="sortDirectionIndicator"
|
||||
persist="hidden ordinal width"
|
||||
hiddenbydefault="true"
|
||||
flex="1" label="&PrimaryEmail.label;"/>
|
||||
</outlinercols>
|
||||
<outlinerbody flex="1" />
|
||||
</outliner>
|
||||
|
||||
</vbox>
|
||||
</page>
|
||||
|
@ -1,6 +1,45 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Addressbook.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999-2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Original Author:
|
||||
* Paul Hangas <hangas@netscape.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var cvPrefs = 0;
|
||||
var addressbook = 0;
|
||||
var gUpdateCardView = 0;
|
||||
var gAddressBookBundle;
|
||||
|
||||
var gTotalCardsElement = null;
|
||||
@ -11,119 +50,119 @@ const kDisplayName = 0;
|
||||
const kLastNameFirst = 1;
|
||||
const kFirstNameFirst = 2;
|
||||
|
||||
var addressBookObserver = {
|
||||
onAssert: function(aDataSource, aSource, aProperty, aTarget)
|
||||
{
|
||||
UpdateAddDeleteCounts();
|
||||
var gAddressBookAbListener = {
|
||||
onItemAdded: function(parentDir, item) {
|
||||
// will not be called
|
||||
},
|
||||
|
||||
onUnassert: function(aDataSource, aSource, aProperty, aTarget)
|
||||
{
|
||||
UpdateAddDeleteCounts();
|
||||
onItemRemoved: function(parentDir, item) {
|
||||
// will only be called when an addressbook is deleted
|
||||
try {
|
||||
var directory = item.QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
// check if the item being removed is the directory
|
||||
// that we are showing in the addressbook
|
||||
// if so, select the personal addressbook (it can't be removed)
|
||||
if (directory && directory == GetAbView().directory) {
|
||||
SelectFirstAddressBook();
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
},
|
||||
|
||||
onChange: function(aDataSource, aSource, aProperty, aOldTarget, aNewTarget)
|
||||
{ },
|
||||
|
||||
onMove: function(aDataSource,
|
||||
aOldSource,
|
||||
aNewSource,
|
||||
aProperty,
|
||||
aTarget)
|
||||
{},
|
||||
|
||||
beginUpdateBatch: function(aDataSource)
|
||||
{},
|
||||
|
||||
endUpdateBatch: function(aDataSource)
|
||||
{}
|
||||
}
|
||||
onItemPropertyChanged: function(item, property, oldValue, newValue) {
|
||||
// will not be called
|
||||
}
|
||||
};
|
||||
|
||||
function OnUnloadAddressBook()
|
||||
{
|
||||
var addrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);
|
||||
addrbookSession.removeAddressBookListener(gAddressBookAbListener);
|
||||
|
||||
RemovePrefObservers();
|
||||
CloseAbView();
|
||||
}
|
||||
|
||||
var gAddressBookAbViewListener = {
|
||||
onSelectionChanged: function() {
|
||||
ResultsPaneSelectionChanged();
|
||||
},
|
||||
onCountChanged: function(total) {
|
||||
SetTotalCardStatus(gAbView.directory.dirName, total);
|
||||
}
|
||||
};
|
||||
|
||||
function GetAbViewListener()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dataSource = top.rdf.GetDataSource("rdf:addressdirectory");
|
||||
dataSource.RemoveObserver (addressBookObserver);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dump(ex + "\n");
|
||||
dump("Error removing from RDF datasource\n");
|
||||
}
|
||||
return gAddressBookAbViewListener;
|
||||
}
|
||||
|
||||
const kPrefMailAddrBookLastNameFirst = "mail.addr_book.lastnamefirst";
|
||||
|
||||
var gMailAddrBookLastNameFirstObserver = {
|
||||
observe: function(subject, topic, value) {
|
||||
if (topic == "nsPref:changed" && value == kPrefMailAddrBookLastNameFirst) {
|
||||
UpdateCardView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AddPrefObservers()
|
||||
{
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
||||
prefBranch.addObserver(kPrefMailAddrBookLastNameFirst, gMailAddrBookLastNameFirstObserver, false);
|
||||
}
|
||||
|
||||
function RemovePrefObservers()
|
||||
{
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
||||
prefBranch.removeObserver(kPrefMailAddrBookLastNameFirst, gMailAddrBookLastNameFirstObserver);
|
||||
}
|
||||
|
||||
function OnLoadAddressBook()
|
||||
{
|
||||
gAddressBookBundle = document.getElementById("bundle_addressBook");
|
||||
verifyAccounts(null); // this will do migration, if we need to.
|
||||
gAddressBookBundle = document.getElementById("bundle_addressBook");
|
||||
verifyAccounts(null); // this will do migration, if we need to.
|
||||
|
||||
top.addressbook = Components.classes["@mozilla.org/addressbook;1"].createInstance();
|
||||
top.addressbook = top.addressbook.QueryInterface(Components.interfaces.nsIAddressBook);
|
||||
top.gUpdateCardView = UpdateCardView;
|
||||
top.addressbook = Components.classes["@mozilla.org/addressbook;1"].createInstance(Components.interfaces.nsIAddressBook);
|
||||
|
||||
InitCommonJS();
|
||||
GetCurrentPrefs();
|
||||
InitCommonJS();
|
||||
|
||||
// FIX ME - later we will be able to use onload from the overlay
|
||||
OnLoadCardView();
|
||||
UpgradeAddressBookResultsPaneUI("mailnews.ui.addressbook_results.version");
|
||||
|
||||
GetCurrentPrefs();
|
||||
|
||||
AddPrefObservers();
|
||||
|
||||
// FIX ME - later we will be able to use onload from the overlay
|
||||
OnLoadCardView();
|
||||
|
||||
try {
|
||||
top.addressbook.setWebShellWindow(window)
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to set webshell window\n");
|
||||
}
|
||||
SetupAbCommandUpdateHandlers();
|
||||
|
||||
SetupCommandUpdateHandlers();
|
||||
|
||||
//workaround - add setTimeout to make sure dynamic overlays get loaded first
|
||||
setTimeout('SelectFirstAddressBook()',0);
|
||||
|
||||
try
|
||||
{
|
||||
var dataSource = top.rdf.GetDataSource("rdf:addressdirectory");
|
||||
dataSource.AddObserver (addressBookObserver);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dump(ex + "\n");
|
||||
dump("Error adding to RDF datasource\n");
|
||||
}
|
||||
//workaround - add setTimeout to make sure dynamic overlays get loaded first
|
||||
setTimeout('SelectFirstAddressBook()',0);
|
||||
|
||||
// add a listener, so we can switch directories if
|
||||
// the current directory is deleted
|
||||
var addrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);
|
||||
// this listener only cares when a directory is removed
|
||||
addrbookSession.addAddressBookListener(gAddressBookAbListener, Components.interfaces.nsIAbListener.directoryRemoved);
|
||||
}
|
||||
|
||||
|
||||
function GetCurrentPrefs()
|
||||
{
|
||||
// prefs
|
||||
if ( cvPrefs == 0 )
|
||||
cvPrefs = new Object;
|
||||
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"];
|
||||
if ( prefs )
|
||||
{
|
||||
prefs = prefs.getService();
|
||||
if ( prefs )
|
||||
prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
}
|
||||
|
||||
if ( prefs )
|
||||
{
|
||||
try {
|
||||
cvPrefs.prefs = prefs;
|
||||
cvPrefs.displayLastNameFirst = prefs.getBoolPref("mail.addr_book.displayName.lastnamefirst");
|
||||
cvPrefs.nameColumn = prefs.getIntPref("mail.addr_book.lastnamefirst");
|
||||
cvPrefs.lastFirstSeparator = ", ";
|
||||
cvPrefs.firstLastSeparator = " ";
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to get the mail.addr_book.displayName.lastnamefirst pref\n");
|
||||
}
|
||||
}
|
||||
cvPrefs.prefs = gPrefs;
|
||||
|
||||
// check "Show Name As" menu item based on pref
|
||||
var menuitemID;
|
||||
switch ( cvPrefs.nameColumn )
|
||||
switch (gPrefs.getIntPref("mail.addr_book.lastnamefirst"))
|
||||
{
|
||||
case kFirstNameFirst:
|
||||
menuitemID = 'firstLastCmd';
|
||||
@ -136,6 +175,7 @@ function GetCurrentPrefs()
|
||||
menuitemID = 'displayNameCmd';
|
||||
break;
|
||||
}
|
||||
|
||||
var menuitem = top.document.getElementById(menuitemID);
|
||||
if ( menuitem )
|
||||
menuitem.setAttribute('checked', 'true');
|
||||
@ -159,65 +199,47 @@ function SetNameColumn(cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
// set pref in file and locally
|
||||
cvPrefs.prefs.setIntPref("mail.addr_book.lastnamefirst", prefValue);
|
||||
cvPrefs.nameColumn = prefValue;
|
||||
|
||||
var selectionArray = RememberResultsTreeSelection();
|
||||
ClearResultsTreeSelection() ;
|
||||
|
||||
RedrawResultsTree();
|
||||
|
||||
WaitUntilDocumentIsLoaded();
|
||||
SortToPreviousSettings();
|
||||
RestoreResultsTreeSelection(selectionArray);
|
||||
}
|
||||
|
||||
|
||||
function CommandUpdate_AddressBook()
|
||||
{
|
||||
goUpdateCommand('button_delete');
|
||||
|
||||
// get selection info from dir pane
|
||||
var oneAddressBookSelected = false;
|
||||
if ( dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1) )
|
||||
oneAddressBookSelected = true;
|
||||
|
||||
// get selection info from results pane
|
||||
var selectedCards = GetSelectedAddresses();
|
||||
var oneOrMoreCardsSelected = false;
|
||||
if ( selectedCards )
|
||||
oneOrMoreCardsSelected = true;
|
||||
|
||||
// set commands to enabled / disabled
|
||||
//goSetCommandEnabled('cmd_PrintCard', oneAddressBookSelected);
|
||||
goSetCommandEnabled('cmd_SortByName', oneAddressBookSelected);
|
||||
goSetCommandEnabled('cmd_SortByEmail', oneAddressBookSelected);
|
||||
goSetCommandEnabled('cmd_SortByWorkPhone', oneAddressBookSelected);
|
||||
goSetCommandEnabled('cmd_SortByOrganization', oneAddressBookSelected);
|
||||
}
|
||||
|
||||
function ResultsPaneSelectionChanged()
|
||||
{
|
||||
UpdateCardView();
|
||||
}
|
||||
|
||||
function UpdateCardView()
|
||||
{
|
||||
if ( resultsTree && resultsTree.selectedItems && (resultsTree.selectedItems.length == 1) )
|
||||
DisplayCardViewPane(resultsTree.selectedItems[0]);
|
||||
else
|
||||
ClearCardViewPane();
|
||||
var card = GetSelectedCard();
|
||||
|
||||
// display the selected card, if exactly one card is selected.
|
||||
// either no cards, or more than one card is selected, clear the pane.
|
||||
OnClickedCard(card)
|
||||
}
|
||||
|
||||
// if card is null, OnClickedCard() must clear the card pane
|
||||
function OnClickedCard(card)
|
||||
{
|
||||
if (card)
|
||||
DisplayCardViewPane(card);
|
||||
else
|
||||
ClearCardViewPane();
|
||||
}
|
||||
|
||||
function AbClose()
|
||||
{
|
||||
top.close();
|
||||
top.close();
|
||||
}
|
||||
|
||||
function AbNewAddressBook()
|
||||
{
|
||||
var dialog = window.openDialog("chrome://messenger/content/addressbook/abAddressBookNameDialog.xul",
|
||||
"",
|
||||
"chrome,titlebar",
|
||||
{okCallback:AbCreateNewAddressBook});
|
||||
var dialog = window.openDialog(
|
||||
"chrome://messenger/content/addressbook/abAddressBookNameDialog.xul",
|
||||
"", "chrome,titlebar", {okCallback:AbCreateNewAddressBook});
|
||||
}
|
||||
|
||||
function AbCreateNewAddressBook(name)
|
||||
@ -226,37 +248,38 @@ function AbCreateNewAddressBook(name)
|
||||
var prefsValue = new Array;
|
||||
prefsAttr[0] = "description";
|
||||
prefsValue[0] = name;
|
||||
top.addressbook.newAddressBook(dirTree.database, resultsTree, 1, prefsAttr, prefsValue);
|
||||
top.addressbook.newAddressBook(dirTree.database, 1, prefsAttr, prefsValue);
|
||||
}
|
||||
|
||||
function AbPrintCard()
|
||||
{
|
||||
dump("print card\n");
|
||||
var selectedItems = GetSelectedAbCards();
|
||||
var numSelected = selectedItems.length;
|
||||
|
||||
var selectedItems = resultsTree.selectedItems;
|
||||
var numSelected = selectedItems.length;
|
||||
if (!numSelected)
|
||||
return;
|
||||
|
||||
var addressbook = Components.classes["@mozilla.org/addressbook;1"].createInstance(Components.interfaces.nsIAddressBook);
|
||||
var uri = GetAbViewURI();
|
||||
if (!uri)
|
||||
return;
|
||||
|
||||
var escapedDirName = escape(addressbook.getAbDatabaseFromURI(uri).directoryName);
|
||||
|
||||
if (numSelected == 0)
|
||||
{
|
||||
dump("AbPrintCard(): No card selected.\n");
|
||||
return false;
|
||||
}
|
||||
var statusFeedback;
|
||||
statusFeedback = Components.classes["@mozilla.org/messenger/statusfeedback;1"].createInstance();
|
||||
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
|
||||
|
||||
var selectionArray = new Array(numSelected);
|
||||
|
||||
var totalCard = 0;
|
||||
|
||||
for(var i = 0; i < numSelected; i++)
|
||||
{
|
||||
var uri = selectedItems[i].getAttribute("id");
|
||||
var cardResource = top.rdf.GetResource(uri);
|
||||
var card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
if (card.printCardUrl.length)
|
||||
var card = selectedItems[i];
|
||||
var printCardUrl = CreatePrintCardUrl(escapedDirName, card);
|
||||
if (printCardUrl)
|
||||
{
|
||||
selectionArray[totalCard++] = card.printCardUrl;
|
||||
dump("printCardUrl = " + card.printCardUrl + "\n");
|
||||
selectionArray[totalCard++] = printCardUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,7 +288,18 @@ function AbPrintCard()
|
||||
"chrome,dialog=no,all",
|
||||
totalCard, selectionArray, statusFeedback);
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
function CreatePrintCardUrl(escapedDirName, card)
|
||||
{
|
||||
var url = "";
|
||||
|
||||
var email = card.primaryEmail;
|
||||
if (email) {
|
||||
url = "addbook:printone?email=" + email + "&folder=" + escapedDirName;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function AbPrintAddressBook()
|
||||
@ -279,44 +313,46 @@ function AbPrintAddressBook()
|
||||
}
|
||||
}
|
||||
|
||||
function AbImport()
|
||||
function AbExport()
|
||||
{
|
||||
try {
|
||||
addressbook.importAddressBook();
|
||||
}
|
||||
catch (ex) {
|
||||
alert("failed to import the addressbook.\n");
|
||||
dump("import failed: " + ex + "\n");
|
||||
}
|
||||
}
|
||||
try {
|
||||
var selectedItems = dirTree.selectedItems;
|
||||
if (selectedItems.length != 1)
|
||||
return;
|
||||
|
||||
/*
|
||||
function AbDelete()
|
||||
{
|
||||
// dump("\AbDelete from XUL\n");
|
||||
var tree = document.getElementById('resultsTree');
|
||||
if ( tree )
|
||||
{
|
||||
//get the selected elements
|
||||
var cardList = tree.selectedItems;
|
||||
//get the current folder
|
||||
var srcDirectory = document.getElementById('resultsTree');
|
||||
dump("srcDirectory = " + srcDirectory + "\n");
|
||||
top.addressbook.deleteCards(tree, srcDirectory, cardList);
|
||||
}
|
||||
}
|
||||
*/
|
||||
var selectedABURI = selectedItems[0].getAttribute('id');
|
||||
var directory = GetDirectoryFromURI(selectedABURI);
|
||||
addressbook.exportAddressBook(directory);
|
||||
}
|
||||
catch (ex) {
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
if (promptService) {
|
||||
var message;
|
||||
switch (ex.result) {
|
||||
case Components.results.NS_ERROR_FILE_ACCESS_DENIED:
|
||||
message = gAddressBookBundle.getString("failedToExportMessageFileAccessDenied");
|
||||
break;
|
||||
case Components.results.NS_ERROR_FILE_NO_DEVICE_SPACE:
|
||||
message = gAddressBookBundle.getString("failedToExportMessageNoDeviceSpace");
|
||||
break;
|
||||
default:
|
||||
message = ex.message;
|
||||
break;
|
||||
}
|
||||
|
||||
promptService.alert(window,
|
||||
gAddressBookBundle.getString("failedToExportTitle"),
|
||||
message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AbDeleteDirectory()
|
||||
{
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
|
||||
promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
|
||||
|
||||
var selArray = dirTree.selectedItems;
|
||||
var count = selArray.length;
|
||||
debugDump("selArray.length = " + count + "\n");
|
||||
if (!count)
|
||||
if (count != 1)
|
||||
return;
|
||||
|
||||
var isPersonalOrCollectedAbsSelectedForDeletion = false;
|
||||
@ -324,111 +360,57 @@ function AbDeleteDirectory()
|
||||
if (!parentArray)
|
||||
return;
|
||||
|
||||
for ( var i = 0; i < count; ++i )
|
||||
{
|
||||
debugDump(" nodeId #" + i + " = " + selArray[i].getAttribute("id") + "\n");
|
||||
|
||||
// check to see if personal or collected address books is selected for deletion.
|
||||
// if yes, prompt the user an appropriate message saying these cannot be deleted
|
||||
// if no, mark the selected items for deletion
|
||||
if ((selArray[i].getAttribute("id") != "moz-abmdbdirectory://history.mab") &&
|
||||
(selArray[i].getAttribute("id") != "moz-abmdbdirectory://abook.mab"))
|
||||
{
|
||||
var parent = selArray[i].parentNode.parentNode;
|
||||
if (parent)
|
||||
{
|
||||
var parentId;
|
||||
if (parent == dirTree)
|
||||
parentId = "moz-abdirectory://";
|
||||
else
|
||||
parentId = parent.getAttribute("id");
|
||||
var selectedABURI = selArray[0].getAttribute("id");
|
||||
|
||||
debugDump(" parentId #" + i + " = " + parentId + "\n");
|
||||
var dirResource = rdf.GetResource(parentId);
|
||||
var parentDir = dirResource.QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
parentArray.AppendElement(parentDir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (promptService)
|
||||
{
|
||||
promptService.alert(window,
|
||||
gAddressBookBundle.getString("cannotDeleteTitle"),
|
||||
gAddressBookBundle.getString("cannotDeleteMessage"));
|
||||
}
|
||||
// check to see if personal or collected address books is selected for deletion.
|
||||
// if yes, prompt the user an appropriate message saying these cannot be deleted
|
||||
if ((selectedABURI != kCollectedAddressbookURI) &&
|
||||
(selectedABURI != kPersonalAddressbookURI)) {
|
||||
var parent = selArray[0].parentNode.parentNode;
|
||||
if (parent) {
|
||||
var parentId;
|
||||
if (parent == dirTree)
|
||||
parentId = "moz-abdirectory://";
|
||||
else
|
||||
parentId = parent.getAttribute("id");
|
||||
|
||||
isPersonalOrCollectedAbsSelectedForDeletion = true;
|
||||
break;
|
||||
}
|
||||
var parentDir = GetDirectoryFromURI(parentId);
|
||||
parentArray.AppendElement(parentDir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||
if (promptService) {
|
||||
promptService.alert(window,
|
||||
gAddressBookBundle.getString("cannotDeleteTitle"),
|
||||
gAddressBookBundle.getString("cannotDeleteMessage"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isPersonalOrCollectedAbsSelectedForDeletion) {
|
||||
var confirmDeleteAddressbook =
|
||||
gAddressBookBundle.getString("confirmDeleteAddressbook");
|
||||
var confirmDeleteMessage;
|
||||
|
||||
var directory = GetDirectoryFromURI(selectedABURI);
|
||||
if (directory.isMailList)
|
||||
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteMailingList");
|
||||
else
|
||||
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteAddressbook");
|
||||
|
||||
if(!window.confirm(confirmDeleteAddressbook))
|
||||
return;
|
||||
if (!window.confirm(confirmDeleteMessage))
|
||||
return;
|
||||
|
||||
top.addressbook.deleteAddressBooks(dirTree.database, parentArray, dirTree.selectedItems);
|
||||
}
|
||||
}
|
||||
|
||||
function clickResultsTree(event)
|
||||
{
|
||||
// we only care about button 0 (left click) events
|
||||
if (event.button != 0) return;
|
||||
|
||||
if (event.target.localName != "treecell" &&
|
||||
event.target.localName != "treeitem")
|
||||
return;
|
||||
|
||||
if ( event.detail == 2 ) top.AbEditCard();
|
||||
}
|
||||
|
||||
function UpdateAddDeleteCounts()
|
||||
{
|
||||
if ( dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1) )
|
||||
{
|
||||
var dirUri = dirTree.selectedItems[0].getAttribute("id");
|
||||
UpdateStatusCardCounts(dirUri);
|
||||
}
|
||||
top.addressbook.deleteAddressBooks(dirTree.database, parentArray, dirTree.selectedItems);
|
||||
SelectFirstAddressBook();
|
||||
}
|
||||
|
||||
function GetTotalCardCountElement()
|
||||
{
|
||||
if(gTotalCardsElement) return gTotalCardsElement;
|
||||
if (gTotalCardsElement)
|
||||
return gTotalCardsElement;
|
||||
|
||||
var totalCardCountElement = document.getElementById('statusText');
|
||||
gTotalCardsElement = totalCardCountElement;
|
||||
return totalCardCountElement;
|
||||
}
|
||||
|
||||
function UpdateStatusCardCounts(uri)
|
||||
{
|
||||
if (top.addressbook)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dirResource = rdf.GetResource(uri);
|
||||
var parentDir = dirResource.QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
if (parentDir && !parentDir.isMailList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var totalCards = parentDir.getTotalCards(false);
|
||||
SetTotalCardStatus(parentDir.dirName, totalCards);
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
dump("Fail to get card total from "+uri+"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
dump("Fail to get directory from "+uri+"\n");
|
||||
}
|
||||
}
|
||||
return gTotalCardsElement;
|
||||
}
|
||||
|
||||
function SetTotalCardStatus(name, total)
|
||||
@ -449,3 +431,8 @@ function SetTotalCardStatus(name, total)
|
||||
else
|
||||
dump("Can't find status bar\n");
|
||||
}
|
||||
|
||||
function AbResultsPaneDoubleClick(card)
|
||||
{
|
||||
AbEditCard(card);
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Seth Spitzer <sspitzer@netscape.com>
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/addressbook.css" type="text/css"?>
|
||||
@ -25,13 +28,15 @@ Rights Reserved.
|
||||
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abDirTreeOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abResultsTreeOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abResultsPaneOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://messenger/content/addressbook/abCardViewOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://communicator/content/communicatorOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % abMainWindowDTD SYSTEM "chrome://messenger/locale/addressbook/abMainWindow.dtd" >
|
||||
%abMainWindowDTD;
|
||||
<!ENTITY % abResultsPaneOverlayDTD SYSTEM "chrome://messenger/locale/addressbook/abResultsPaneOverlay.dtd" >
|
||||
%abResultsPaneOverlayDTD;
|
||||
<!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
|
||||
%messengerDTD;
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
|
||||
@ -53,7 +58,7 @@ Rights Reserved.
|
||||
<stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
|
||||
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/addressbook.js"/>
|
||||
@ -61,7 +66,7 @@ Rights Reserved.
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/msgPrintEngine.js"/>
|
||||
|
||||
<commandset id="tasksCommands">
|
||||
<commandset id="addressBook">
|
||||
<commandset id="CommandUpdate_AddressBook"
|
||||
commandupdater="true"
|
||||
events="focus,tree-select"
|
||||
@ -71,11 +76,12 @@ Rights Reserved.
|
||||
<command id="cmd_newNavigator"/>
|
||||
<command id="cmd_newEditor"/>
|
||||
<command id="cmd_printSetup" oncommand="goPageSetup()"/>
|
||||
<command id="cmd_PrintCard" oncommand="AbPrintCard()"/>
|
||||
<command id="cmd_printCard" oncommand="AbPrintCard()"/>
|
||||
<command id="cmd_quit"/>
|
||||
<command id="cmd_close" oncommand="AbClose()"/>
|
||||
<command id="cmd_properties" oncommand="goDoCommand('button_edit');"/>
|
||||
<command id='cmd_selectAll'/>
|
||||
<commandset id="tasksCommands"/>
|
||||
<command id="toggleSidebar"/>
|
||||
</commandset>
|
||||
|
||||
@ -95,7 +101,7 @@ Rights Reserved.
|
||||
<keyset id="tasksKeys">
|
||||
<!-- File Menu -->
|
||||
<key id="key_newNavigator"/>
|
||||
<key id="key_PrintCard" key="&printCardViewCmd.key;" command="cmd_PrintCard" modifiers="accel"/>
|
||||
<key id="key_printCard" key="&printCardViewCmd.key;" command="cmd_printCard" modifiers="accel"/>
|
||||
<key id="key_close"/>
|
||||
<key id="key_quit"/>
|
||||
<!-- Edit Menu -->
|
||||
@ -125,9 +131,10 @@ Rights Reserved.
|
||||
<menuitem id="menu_close"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="toImport()"/>
|
||||
<menuitem label="&exportCmd.label;" accesskey="&exportCmd.accesskey;" oncommand="AbExport()"/>
|
||||
<menuseparator/>
|
||||
<!--Page setup gets overlaid here from platformGlobalOverlay.xul / -->
|
||||
<menuitem id="printMenuItem" label="&printCardViewCmd.label;" accesskey="&printCardViewCmd.accesskey;" key="key_PrintCard" command="cmd_PrintCard"/>
|
||||
<menuitem id="printMenuItem" label="&printCardViewCmd.label;" accesskey="&printCardViewCmd.accesskey;" key="key_printCard" command="cmd_printCard"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
@ -155,6 +162,11 @@ Rights Reserved.
|
||||
accesskey="&showAbToolbarCmd.accesskey;"
|
||||
oncommand="goToggleToolbar('abToolbar', 'menu_showAbToolbar')"
|
||||
checked="true" type="checkbox"/>
|
||||
<menuitem id="menu_showCardPane"
|
||||
label="&showCardPane.label;"
|
||||
accesskey="&showCardPane.accesskey;"
|
||||
oncommand="goToggleSplitter('results-splitter', 'menu_showCardPane')"
|
||||
checked="true" type="checkbox"/>
|
||||
<menuitem id="menu_showTaskbar" type="checkbox"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
@ -179,27 +191,58 @@ Rights Reserved.
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&sortMenu.label;" accesskey="&sortMenu.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem label="&sortByNameCmd.label;"
|
||||
id="cmd_SortByName"
|
||||
disabled="true"
|
||||
accesskey="&SortByName.accesskey;"
|
||||
oncommand="top.SortResultPane('NameColumn', 'http://home.netscape.com/NC-rdf#DisplayName')" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&sortByEmailCmd.label;"
|
||||
id="cmd_SortByEmail"
|
||||
disabled="true"
|
||||
accesskey="&SortByEmail.accesskey;"
|
||||
oncommand="top.SortResultPane('EmailColumn', 'http://home.netscape.com/NC-rdf#PrimaryEmail')" name="sortas" type="radio"/>
|
||||
<menuitem label="&sortByWorkPhoneCmd.label;"
|
||||
<menupopup id="sortMenuPopup" onpopupshowing="InitViewSortByMenu()">
|
||||
<menuitem label="&GeneratedName.label;"
|
||||
id="cmd_SortByGeneratedName"
|
||||
accesskey="&GeneratedName.accesskey;"
|
||||
oncommand="SortResultPane('GeneratedName');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&PrimaryEmail.label;"
|
||||
id="cmd_SortByPrimaryEmail"
|
||||
accesskey="&PrimaryEmail.accesskey;"
|
||||
oncommand="SortResultPane('PrimaryEmail');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&Company.label;"
|
||||
id="cmd_SortByCompany"
|
||||
accesskey="&Company.accesskey;"
|
||||
oncommand="SortResultPane('Company');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&NickName.label;"
|
||||
id="cmd_SortByNickName"
|
||||
accesskey="&NickName.accesskey;"
|
||||
oncommand="SortResultPane('NickName');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&SecondEmail.label;"
|
||||
id="cmd_SortBySecondEmail"
|
||||
accesskey="&SecondEmail.accesskey;"
|
||||
oncommand="SortResultPane('SecondEmail');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&Department.label;"
|
||||
id="cmd_SortByDepartment"
|
||||
accesskey="&Department.accesskey;"
|
||||
oncommand="SortResultPane('Department');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&JobTitle.label;"
|
||||
id="cmd_SortByJobTitle"
|
||||
accesskey="&JobTitle.accesskey;"
|
||||
oncommand="SortResultPane('JobTitle');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&CellularNumber.label;"
|
||||
id="cmd_SortByCellularNumber"
|
||||
accesskey="&CellularNumber.accesskey;"
|
||||
oncommand="SortResultPane('CellularNumber');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&PagerNumber.label;"
|
||||
id="cmd_SortByPagerNumber"
|
||||
accesskey="&PagerNumber.accesskey;"
|
||||
oncommand="SortResultPane('PagerNumber');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&FaxNumber.label;"
|
||||
id="cmd_SortByFaxNumber"
|
||||
accesskey="&FaxNumber.accesskey;"
|
||||
oncommand="SortResultPane('FaxNumber');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&HomePhone.label;"
|
||||
id="cmd_SortByHomePhone"
|
||||
accesskey="&HomePhone.accesskey;"
|
||||
oncommand="SortResultPane('HomePhone');" name="sortas" type="radio" checked="true"/>
|
||||
<menuitem label="&WorkPhone.label;"
|
||||
id="cmd_SortByWorkPhone"
|
||||
disabled="true"
|
||||
accesskey="&SortByWorkPhone.accesskey;"
|
||||
oncommand="top.SortResultPane('WorkPhoneColumn', 'http://home.netscape.com/NC-rdf#WorkPhone')" name="sortas" type="radio"/>
|
||||
<menuitem label="&sortByOrganizationCmd.label;"
|
||||
id="cmd_SortByOrganization"
|
||||
disabled="true"
|
||||
accesskey="&SortByOrganization.accesskey;"
|
||||
oncommand="top.SortResultPane('OrganizationColumn', 'http://home.netscape.com/NC-rdf#Company')" name="sortas" type="radio"/>
|
||||
accesskey="&WorkPhone.accesskey;"
|
||||
oncommand="SortResultPane('WorkPhone');" name="sortas" type="radio" checked="true"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="sortAscending" type="radio" name="sortdirection" label="&sortAscending.label;" accesskey="&sortAscending.accesskey;" oncommand="AbSortAscending()"/>
|
||||
<menuitem id="sortDescending" type="radio" name="sortdirection" label="&sortDescending.label;" accesskey="&sortDescending.accesskey;" oncommand="AbSortDescending()"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
@ -251,9 +294,9 @@ Rights Reserved.
|
||||
|
||||
<vbox flex="100%" style="min-width:100px">
|
||||
|
||||
<!-- results tree -->
|
||||
<!-- results pane -->
|
||||
<vbox id="results_box" flex="1">
|
||||
<tree id="resultsTree" flex="1" style="height:0px"/>
|
||||
<outliner id="abResultsOutliner" flex="2" persist="height" />
|
||||
</vbox>
|
||||
|
||||
<splitter id="results-splitter" collapse="after" persist="state">
|
||||
@ -264,12 +307,7 @@ Rights Reserved.
|
||||
<hbox id="CardViewOuterBox" flex="1">
|
||||
<vbox id="CardViewBox" style="height:170px; min-height:1px; min-width:1px"/>
|
||||
</hbox>
|
||||
|
||||
|
||||
|
||||
</vbox>
|
||||
|
||||
|
||||
</hbox>
|
||||
|
||||
<statusbar id="status-bar" class="chromeclass-status">
|
||||
|
@ -4,7 +4,6 @@ abCardViewOverlay.dtd
|
||||
abDirTreeOverlay.dtd
|
||||
abMainWindow.dtd
|
||||
abNewCardDialog.dtd
|
||||
abResultsTreeOverlay.dtd
|
||||
abSelectAddressesDialog.dtd
|
||||
abMailListDialog.dtd
|
||||
addressBook.properties
|
||||
|
@ -19,5 +19,5 @@ Rights Reserved.
|
||||
-->
|
||||
|
||||
<!-- Labels -->
|
||||
<!ENTITY name.label "Address Book Name">
|
||||
<!ENTITY title.label "New Address Book">
|
||||
<!ENTITY name.label "Address Book Name">
|
||||
<!ENTITY title.label "New Address Book">
|
||||
|
@ -18,7 +18,6 @@ Communications Corporation. Portions created by Netscape are
|
||||
Rights Reserved.
|
||||
-->
|
||||
|
||||
<!-- Labels -->
|
||||
<!ENTITY Name.tab "Name">
|
||||
<!ENTITY Name.box "Name">
|
||||
<!ENTITY FirstName.label "First:">
|
||||
|
@ -23,3 +23,9 @@ Rights Reserved.
|
||||
<!ENTITY other.heading "Other">
|
||||
<!ENTITY phone.heading "Phone">
|
||||
<!ENTITY work.heading "Work">
|
||||
<!-- Special Box Headings, for mailing lists -->
|
||||
<!ENTITY description.heading "Description">
|
||||
<!ENTITY addresses.heading "Addresses">
|
||||
<!-- For Map It -->
|
||||
<!ENTITY mapItButton.label "Map It!">
|
||||
|
||||
|
@ -37,8 +37,9 @@ Rights Reserved.
|
||||
<!-- LOCALIZATION NOTE (newDirectoryCmd.accesskey) : DONT_TRANSLATE -->
|
||||
<!ENTITY newDirectoryCmd.accesskey "d">
|
||||
<!ENTITY importCmd.label "Import...">
|
||||
<!ENTITY importCmd.accesskey "i">
|
||||
<!ENTITY exportCmd.label ".Export...">
|
||||
<!ENTITY importCmd.accesskey "I">
|
||||
<!ENTITY exportCmd.label "Export...">
|
||||
<!ENTITY exportCmd.accesskey "E">
|
||||
<!ENTITY printPreviewCmd.label ".Print Preview">
|
||||
<!ENTITY printCardViewCmd.label "Print Card...">
|
||||
<!ENTITY printCardViewCmd.accesskey "p">
|
||||
@ -59,7 +60,9 @@ Rights Reserved.
|
||||
<!ENTITY showAbToolbarCmd.label "Address Book Toolbar">
|
||||
<!-- LOCALIZATION NOTE (showAbToolbarCmd.accesskey) : DONT_TRANSLATE -->
|
||||
<!ENTITY showAbToolbarCmd.accesskey "o">
|
||||
<!ENTITY showCardPane.label ".Card Pane">
|
||||
<!ENTITY showCardPane.label "Card Summary">
|
||||
<!ENTITY showCardPane.accesskey "C">
|
||||
|
||||
<!ENTITY menu_ShowNameAs.label "Show Name As">
|
||||
<!ENTITY menu_ShowNameAs.accesskey "n">
|
||||
<!ENTITY firstLastCmd.label "First Last">
|
||||
@ -69,15 +72,6 @@ Rights Reserved.
|
||||
<!ENTITY displayNameCmd.label "Display Name">
|
||||
<!ENTITY displayNameCmd.accesskey "d">
|
||||
<!ENTITY sortMenu.label "Sort by">
|
||||
<!ENTITY sortMenu.accesskey "s">
|
||||
<!ENTITY sortByNameCmd.label "Name">
|
||||
<!ENTITY SortByName.accesskey "n">
|
||||
<!ENTITY sortByEmailCmd.label "Email">
|
||||
<!ENTITY SortByEmail.accesskey "e">
|
||||
<!ENTITY sortByWorkPhoneCmd.label "Work Phone">
|
||||
<!ENTITY SortByWorkPhone.accesskey "w">
|
||||
<!ENTITY sortByOrganizationCmd.label "Organization">
|
||||
<!ENTITY SortByOrganization.accesskey "O">
|
||||
<!ENTITY stopSearchingCmd.label ".Stop Searching">
|
||||
|
||||
<!-- Toolbar items -->
|
||||
|
@ -1,35 +0,0 @@
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
-->
|
||||
|
||||
<!-- Column Headings -->
|
||||
<!ENTITY nameColumn.label "Name">
|
||||
<!ENTITY emailColumn.label "Email">
|
||||
<!ENTITY workPhoneColumn.label "Work Phone">
|
||||
<!ENTITY organizationColumn.label "Organization">
|
||||
<!ENTITY composeEmail.label "Compose Email To...">
|
||||
<!ENTITY composeEmail.accesskey "C">
|
||||
<!ENTITY deleteAddrBookCard.label "Delete">
|
||||
<!ENTITY deleteAddrBookCard.accesskey "D">
|
||||
<!ENTITY newAddrBookCard.label "New Card...">
|
||||
<!ENTITY newAddrBookCard.accesskey "N">
|
||||
<!ENTITY newAddrBookMailingList.label "New Mailing List...">
|
||||
<!ENTITY newAddrBookMailingList.accesskey "M">
|
||||
<!ENTITY addrBookCardProperties.label "Card Properties...">
|
||||
<!ENTITY addrBookCardProperties.accesskey "P">
|
@ -17,11 +17,8 @@ Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
-->
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<!ENTITY selectAddressWindow.title "Select Addresses">
|
||||
|
||||
<!-- Buttons -->
|
||||
<!ENTITY toButton.label "To:">
|
||||
<!ENTITY ccButton.label "Cc:">
|
||||
@ -29,7 +26,6 @@ Rights Reserved.
|
||||
<!ENTITY newButton.label "New...">
|
||||
<!ENTITY editButton.label "Edit...">
|
||||
<!ENTITY removeButton.label "Remove">
|
||||
|
||||
<!-- Tooltips items -->
|
||||
<!ENTITY addressPickerSearchButton.tooltip "Search the selected address book">
|
||||
<!ENTITY addressPickerNewButton.tooltip "Create a new address book card">
|
||||
|
@ -18,29 +18,34 @@
|
||||
# Contributor(s):
|
||||
# Paul Hangas <hangas@netscape.com>
|
||||
# Alec Flett <alecf@netscape.com>
|
||||
# Seth Spitzer <sspitzer@netscape.com>
|
||||
#
|
||||
|
||||
#
|
||||
# The following are used by the Mailing list dialog
|
||||
#
|
||||
emptyListName=You must enter a list name.
|
||||
lastFirstSeparator=,
|
||||
firstLastSeparator=
|
||||
lastFirstFormat=%S, %S
|
||||
firstLastFormat=%S %S
|
||||
newCardTitle=New card for %S
|
||||
editCardTitle=Card for %S
|
||||
viewCardTitle=Card for %S
|
||||
cannotDeleteTitle=Personal and Collected address books cannot be deleted
|
||||
cannotDeleteMessage=You are not allowed to delete the Personal and Collected Addresses address books. Please deselect them for your delete operation.
|
||||
confirmDeleteAddressbook=Are you sure you want to delete the Selected Addressbooks and Mailing Lists?
|
||||
viewListTitle=Mailing List: %S
|
||||
mailListNameExists=A Mailing List with that name already exist. Please choose a different name.
|
||||
|
||||
# used in the addressbook
|
||||
cannotDeleteTitle=Delete Failed
|
||||
cannotDeleteMessage=You are not allowed to delete the Personal or Collected Addresses address books.
|
||||
confirmDeleteAddressbook=Are you sure you want to delete the selected address book?
|
||||
confirmDeleteMailingList=Are you sure you want to delete the selected mailing list?
|
||||
|
||||
propertyName=Name
|
||||
propertyNickname=Nickname
|
||||
propertyDisplayName=Display Name
|
||||
propertyWork=Work
|
||||
propertyHome=Home
|
||||
propertyFax=Fax
|
||||
propertyCellular=Cellular
|
||||
propertyCellular=Mobile
|
||||
propertyPager=Pager
|
||||
propertyCustom1=Custom 1
|
||||
propertyCustom2=Custom 2
|
||||
@ -71,3 +76,12 @@ invalidName=Please enter a valid Name.
|
||||
invalidHostname=Please enter a valid Hostname.
|
||||
invalidPortNumber=Please enter a valid Port Number.
|
||||
invalidResults=Please enter a valid number in the results field.
|
||||
|
||||
#For importing / exporting
|
||||
ExportAddressBookTitle=Export Address Book
|
||||
LDIFFiles=LDIF (*.ldi,*.ldif)
|
||||
CSVFiles=Comma Separated (*.csv)
|
||||
TABFiles=Tab Delimited (*.tab,*.txt)
|
||||
failedToExportTitle=Export Failed
|
||||
failedToExportMessageNoDeviceSpace=Failed to export addressbook, no space left on device.
|
||||
failedToExportMessageFileAccessDenied=Failed to export addressbook, file access denied.
|
||||
|
@ -31,7 +31,6 @@ CHROME_L10N = \
|
||||
.\abDirTreeOverlay.dtd \
|
||||
.\abMainWindow.dtd \
|
||||
.\abNewCardDialog.dtd \
|
||||
.\abResultsTreeOverlay.dtd \
|
||||
.\abSelectAddressesDialog.dtd \
|
||||
.\abMailListDialog.dtd \
|
||||
.\addressBook.properties \
|
||||
|
@ -52,14 +52,13 @@ REQUIRES = xpcom \
|
||||
msgcompose \
|
||||
appcomps \
|
||||
intl \
|
||||
import \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsAddressBook.cpp \
|
||||
nsAddrBookSession.cpp \
|
||||
nsAbRDFDataSource.cpp \
|
||||
nsAbMDBRDFResource.cpp \
|
||||
nsCardDataSource.cpp \
|
||||
nsDirectoryDataSource.cpp \
|
||||
nsAbCardProperty.cpp \
|
||||
nsDirPrefs.cpp \
|
||||
@ -83,14 +82,13 @@ CPPSRCS = \
|
||||
nsAbBooleanExpression.cpp \
|
||||
nsAbDirectoryRDFResource.cpp \
|
||||
nsAbQueryStringToExpression.cpp \
|
||||
nsAbView.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsAddressBook.h \
|
||||
nsAddrBookSession.h \
|
||||
nsAbRDFDataSource.h \
|
||||
nsAbMDBRDFResource.h \
|
||||
nsCardDataSource.h \
|
||||
nsDirectoryDataSource.h \
|
||||
nsAbCardProperty.h \
|
||||
nsDirPrefs.h \
|
||||
@ -112,6 +110,7 @@ EXPORTS = \
|
||||
nsAbDirSearchListener.h \
|
||||
nsAbBooleanExpression.h \
|
||||
nsAbDirectoryRDFResource.h \
|
||||
nsAbView.h \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
|
@ -45,6 +45,8 @@ REQUIRES = xpcom \
|
||||
content \
|
||||
mozldap \
|
||||
intl \
|
||||
layout_xul \
|
||||
import \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
@ -56,8 +58,6 @@ EXPORTS= \
|
||||
nsAddressBook.h \
|
||||
nsAddrBookSession.h \
|
||||
nsAbRDFDataSource.h \
|
||||
nsAbMDBRDFResource.h \
|
||||
nsCardDataSource.h \
|
||||
nsDirectoryDataSource.h \
|
||||
nsAbCardProperty.h \
|
||||
nsDirPrefs.h \
|
||||
@ -80,6 +80,7 @@ EXPORTS= \
|
||||
nsAbDirectoryQuery.h \
|
||||
nsAbDirectoryQueryProxy.h \
|
||||
nsAbDirSearchListener.h \
|
||||
nsAbView.h \
|
||||
!if !defined(DISABLE_LDAP)
|
||||
nsAbLDAPDirectoryQuery.h \
|
||||
nsAbLDAPDirectory.h \
|
||||
@ -100,8 +101,6 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsAddressBook.obj \
|
||||
.\$(OBJDIR)\nsAddrBookSession.obj \
|
||||
.\$(OBJDIR)\nsAbRDFDataSource.obj \
|
||||
.\$(OBJDIR)\nsAbMDBRDFResource.obj \
|
||||
.\$(OBJDIR)\nsCardDataSource.obj \
|
||||
.\$(OBJDIR)\nsDirectoryDataSource.obj \
|
||||
.\$(OBJDIR)\nsAbCardProperty.obj \
|
||||
.\$(OBJDIR)\nsDirPrefs.obj \
|
||||
@ -126,6 +125,7 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsAbDirectoryQuery.obj \
|
||||
.\$(OBJDIR)\nsAbDirectoryQueryProxy.obj \
|
||||
.\$(OBJDIR)\nsAbDirSearchListener.obj \
|
||||
.\$(OBJDIR)\nsAbView.obj \
|
||||
!if !defined(DISABLE_LDAP)
|
||||
.\$(OBJDIR)\nsAbLDAPDirectory.obj \
|
||||
.\$(OBJDIR)\nsAbLDAPDirFactory.obj \
|
||||
|
@ -41,8 +41,6 @@
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAbSyncDriver, nsIAbSyncDriver)
|
||||
|
||||
static NS_DEFINE_CID(kAbSync, NS_ABSYNC_SERVICE_CID);
|
||||
|
||||
nsAbSyncDriver::nsAbSyncDriver()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
@ -84,7 +82,7 @@ NS_IMETHODIMP nsAbSyncDriver::OnStopOperation(PRInt32 aTransactionID, nsresult a
|
||||
NS_IMETHODIMP nsAbSyncDriver::KickIt()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIAbSync> sync(do_GetService(kAbSync, &rv));
|
||||
nsCOMPtr<nsIAbSync> sync(do_GetService(NS_ABSYNC_SERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Add ourselves to the party!
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
@ -52,34 +53,24 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "prmem.h"
|
||||
|
||||
// For the new pref API's
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kAbCardPropertyCID, NS_ABCARDPROPERTY_CID);
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDBCID, NS_ADDRDATABASE_CID);
|
||||
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAbAddressCollecter, nsIAbAddressCollecter)
|
||||
|
||||
static const char *PREF_COLLECT_EMAIL_ADDRESS_ENABLE_SIZE_LIMIT = "mail.collect_email_address_enable_size_limit";
|
||||
static const char *PREF_COLLECT_EMAIL_ADDRESS_SIZE_LIMIT = "mail.collect_email_address_size_limit";
|
||||
#define PREF_COLLECT_EMAIL_ADDRESS_ENABLE_SIZE_LIMIT "mail.collect_email_address_enable_size_limit"
|
||||
#define PREF_COLLECT_EMAIL_ADDRESS_SIZE_LIMIT "mail.collect_email_address_size_limit"
|
||||
|
||||
nsAbAddressCollecter::nsAbAddressCollecter()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
maxCABsize = -1;
|
||||
sizeLimitEnabled = -1;
|
||||
|
||||
//set up the pref callbacks:
|
||||
setupPrefs();
|
||||
m_maxCABsize = -1;
|
||||
m_sizeLimitEnabled = PR_FALSE;
|
||||
}
|
||||
|
||||
nsAbAddressCollecter::~nsAbAddressCollecter()
|
||||
{
|
||||
if (m_historyAB)
|
||||
{
|
||||
m_historyAB->Commit(kSessionCommit);
|
||||
m_historyAB->Commit(nsAddrDBCommitType::kSessionCommit);
|
||||
m_historyAB->Close(PR_FALSE);
|
||||
m_historyAB = nsnull;
|
||||
}
|
||||
@ -106,25 +97,9 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if(sizeLimitEnabled == -1){
|
||||
rv = pPref->GetBoolPref(PREF_COLLECT_EMAIL_ADDRESS_ENABLE_SIZE_LIMIT, &sizeLimitEnabled);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
//maxCABsize = 20;
|
||||
if(sizeLimitEnabled && maxCABsize == -1){
|
||||
PRInt32 max = 0;
|
||||
rv = pPref->GetIntPref(PREF_COLLECT_EMAIL_ADDRESS_SIZE_LIMIT, &max);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
maxCABsize = max;
|
||||
}
|
||||
|
||||
if (!m_historyAB)
|
||||
{
|
||||
rv = OpenHistoryAB(getter_AddRefs(m_historyAB));
|
||||
@ -138,7 +113,7 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address)
|
||||
char *addresses;
|
||||
|
||||
nsresult res = NS_OK;
|
||||
nsCOMPtr<nsIMsgHeaderParser> pHeader = do_GetService(kMsgHeaderParserCID, &res);
|
||||
nsCOMPtr<nsIMsgHeaderParser> pHeader = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID, &res);
|
||||
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
@ -159,12 +134,11 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address)
|
||||
nsCOMPtr <nsIAbCard> existingCard;
|
||||
nsCOMPtr <nsIAbCard> cardInstance;
|
||||
|
||||
rv = m_historyAB->GetCardForEmailAddress(m_historyDirectory, curAddress, getter_AddRefs(existingCard));
|
||||
rv = m_historyAB->GetCardFromAttribute(m_historyDirectory, kPriEmailColumn, curAddress, PR_TRUE /* caseInsensitive */, getter_AddRefs(existingCard));
|
||||
|
||||
if (!existingCard)
|
||||
{
|
||||
nsCOMPtr<nsIAbCard> senderCard;
|
||||
rv = nsComponentManager::CreateInstance(kAbCardPropertyCID, nsnull, NS_GET_IID(nsIAbCard), getter_AddRefs(senderCard));
|
||||
nsCOMPtr<nsIAbCard> senderCard = do_CreateInstance(NS_ABCARDPROPERTY_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && senderCard)
|
||||
{
|
||||
if (curName && nsCRT::strlen(curName) > 0)
|
||||
@ -178,23 +152,29 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address)
|
||||
if (atSignIndex > 0)
|
||||
{
|
||||
senderFromEmail.Truncate(atSignIndex);
|
||||
senderCard->SetDisplayName((PRUnichar*)senderFromEmail.get());
|
||||
senderCard->SetDisplayName(senderFromEmail.get());
|
||||
}
|
||||
}
|
||||
nsAutoString email; email.AssignWithConversion(curAddress);
|
||||
senderCard->SetPrimaryEmail((PRUnichar*)email.get());
|
||||
senderCard->AddCardToDatabase(kCollectedAddressbookUri, getter_AddRefs (cardInstance));
|
||||
senderCard->SetPrimaryEmail(email.get());
|
||||
|
||||
rv = AddCardToCollectedAddressBook(senderCard);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
}
|
||||
else //address is already in the CAB
|
||||
{
|
||||
if(sizeLimitEnabled)
|
||||
if (m_sizeLimitEnabled)
|
||||
{
|
||||
//remove card from ab, and
|
||||
m_historyAB->DeleteCard( existingCard, PR_TRUE );
|
||||
// XXX todo
|
||||
// there has to be a better way to do this, without deleting
|
||||
// and adding the card. perhaps using modified time
|
||||
// this doesn't seem like the best way to do LRU
|
||||
m_historyAB->DeleteCard(existingCard, PR_TRUE /* notify */);
|
||||
SetNamesForCard(existingCard, curName);
|
||||
//append it to the bottom.
|
||||
existingCard->AddCardToDatabase(kCollectedAddressbookUri, getter_AddRefs (cardInstance));
|
||||
rv = AddCardToCollectedAddressBook(existingCard);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -203,15 +183,15 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address)
|
||||
}
|
||||
}
|
||||
|
||||
if(sizeLimitEnabled)
|
||||
if (m_sizeLimitEnabled)
|
||||
{
|
||||
PRUint32 count = 0;
|
||||
rv = m_historyAB->GetCardCount( &count );
|
||||
|
||||
if( count > (PRUint32)maxCABsize )
|
||||
rv = m_historyAB->RemoveExtraCardsInCab(count, maxCABsize);
|
||||
if( count > (PRUint32)m_maxCABsize )
|
||||
rv = m_historyAB->RemoveExtraCardsInCab(count, m_maxCABsize);
|
||||
|
||||
} //if sizeLimitEnabled
|
||||
} //if m_sizeLimitEnabled
|
||||
}
|
||||
curName += strlen(curName) + 1;
|
||||
curAddress += strlen(curAddress) + 1;
|
||||
@ -234,7 +214,7 @@ nsresult nsAbAddressCollecter::OpenHistoryAB(nsIAddrDatabase **aDatabase)
|
||||
nsFileSpec* dbPath = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->GetUserProfileDirectory(&dbPath);
|
||||
|
||||
@ -243,7 +223,7 @@ nsresult nsAbAddressCollecter::OpenHistoryAB(nsIAddrDatabase **aDatabase)
|
||||
(*dbPath) += kCollectedAddressbook;
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> addrDBFactory =
|
||||
do_GetService(kAddressBookDBCID, &rv);
|
||||
do_GetService(NS_ADDRDATABASE_CONTRACTID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
{
|
||||
@ -256,7 +236,7 @@ nsresult nsAbAddressCollecter::OpenHistoryAB(nsIAddrDatabase **aDatabase)
|
||||
}
|
||||
delete dbPath;
|
||||
}
|
||||
nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv));
|
||||
nsCOMPtr<nsIRDFService> rdfService(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr <nsIRDFResource> resource;
|
||||
@ -292,6 +272,7 @@ nsresult nsAbAddressCollecter::IsDomainExcluded(const char *address, nsIPref *pP
|
||||
char *rest = NS_CONST_CAST(char*,(const char*)excludedDomainList);
|
||||
nsCAutoString str;
|
||||
|
||||
// XXX todo, fix this leak
|
||||
token = nsCRT::strtok(rest, ",", &rest);
|
||||
while (token && *token)
|
||||
{
|
||||
@ -317,24 +298,17 @@ nsresult nsAbAddressCollecter::SetNamesForCard(nsIAbCard *senderCard, const char
|
||||
{
|
||||
char *firstName = nsnull;
|
||||
char *lastName = nsnull;
|
||||
PRUnichar *unicodeStr = nsnull;
|
||||
|
||||
senderCard->SetDisplayName(NS_ConvertUTF8toUCS2(fullName).get());
|
||||
|
||||
INTL_ConvertToUnicode((const char *)fullName, nsCRT::strlen(fullName), (void**)&unicodeStr);
|
||||
senderCard->SetDisplayName(unicodeStr);
|
||||
PR_Free(unicodeStr);
|
||||
nsresult rv = SplitFullName (fullName, &firstName, &lastName);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
INTL_ConvertToUnicode((const char *)firstName, nsCRT::strlen(firstName), (void**)&unicodeStr);
|
||||
senderCard->SetFirstName(unicodeStr);
|
||||
PR_Free(unicodeStr);
|
||||
if (lastName) {
|
||||
INTL_ConvertToUnicode((const char *)lastName, nsCRT::strlen(lastName), (void**)&unicodeStr);
|
||||
senderCard->SetLastName(unicodeStr);
|
||||
PR_Free(unicodeStr);
|
||||
}
|
||||
}
|
||||
senderCard->SetFirstName(NS_ConvertUTF8toUCS2(firstName).get());
|
||||
|
||||
if (lastName)
|
||||
senderCard->SetLastName(NS_ConvertUTF8toUCS2(lastName).get());
|
||||
}
|
||||
PR_FREEIF(firstName);
|
||||
PR_FREEIF(lastName);
|
||||
return rv;
|
||||
@ -374,40 +348,66 @@ nsresult nsAbAddressCollecter::SplitFullName (const char *fullName, char **first
|
||||
}
|
||||
|
||||
int PR_CALLBACK
|
||||
nsAbAddressCollecter::collectEmailAddressEnableSizeLimitPrefChanged(const char *newpref, void *data){
|
||||
nsAbAddressCollecter::collectEmailAddressEnableSizeLimitPrefChanged(const char *newpref, void *data)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAbAddressCollecter *adCol = (nsAbAddressCollecter *) data;
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));
|
||||
if(NS_FAILED(pPref->GetBoolPref(PREF_COLLECT_EMAIL_ADDRESS_ENABLE_SIZE_LIMIT, &adCol->sizeLimitEnabled))){
|
||||
adCol->sizeLimitEnabled = PR_TRUE;
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
if(NS_FAILED(pPref->GetBoolPref(PREF_COLLECT_EMAIL_ADDRESS_ENABLE_SIZE_LIMIT, &adCol->m_sizeLimitEnabled))){
|
||||
adCol->m_sizeLimitEnabled = PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PR_CALLBACK
|
||||
nsAbAddressCollecter::collectEmailAddressSizeLimitPrefChanged(const char *newpref, void *data){
|
||||
nsAbAddressCollecter::collectEmailAddressSizeLimitPrefChanged(const char *newpref, void *data)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 max = 0;
|
||||
nsAbAddressCollecter *adCol = (nsAbAddressCollecter *) data;
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));
|
||||
if(NS_FAILED(pPref->GetIntPref(PREF_COLLECT_EMAIL_ADDRESS_SIZE_LIMIT, &max))){
|
||||
adCol->maxCABsize = 0;
|
||||
} else
|
||||
adCol->maxCABsize = max;
|
||||
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
if(NS_FAILED(pPref->GetIntPref(PREF_COLLECT_EMAIL_ADDRESS_SIZE_LIMIT, &adCol->m_maxCABsize))){
|
||||
adCol->m_maxCABsize = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nsAbAddressCollecter::setupPrefs(void){
|
||||
nsresult nsAbAddressCollecter::Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = pPref->RegisterCallback(PREF_COLLECT_EMAIL_ADDRESS_ENABLE_SIZE_LIMIT, collectEmailAddressEnableSizeLimitPrefChanged, this);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = pPref->RegisterCallback(PREF_COLLECT_EMAIL_ADDRESS_SIZE_LIMIT, collectEmailAddressSizeLimitPrefChanged, this);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
pPref->RegisterCallback(PREF_COLLECT_EMAIL_ADDRESS_ENABLE_SIZE_LIMIT, collectEmailAddressEnableSizeLimitPrefChanged, this);
|
||||
pPref->RegisterCallback(PREF_COLLECT_EMAIL_ADDRESS_SIZE_LIMIT, collectEmailAddressSizeLimitPrefChanged, this);
|
||||
rv = pPref->GetBoolPref(PREF_COLLECT_EMAIL_ADDRESS_ENABLE_SIZE_LIMIT, &m_sizeLimitEnabled);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = pPref->GetIntPref(PREF_COLLECT_EMAIL_ADDRESS_SIZE_LIMIT, &m_maxCABsize);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbAddressCollecter::AddCardToCollectedAddressBook(nsIAbCard *card)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(card);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFService> rdf(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> res;
|
||||
rv = rdf->GetResource(kCollectedAddressbookUri, getter_AddRefs(res));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(res, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr <nsIAbCard> addedCard;
|
||||
rv = directory->AddCard(card, getter_AddRefs(addedCard));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return rv;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -43,6 +44,7 @@
|
||||
#include "nsIAbAddressCollecter.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsAddrDatabase.h"
|
||||
#include "nsIAbCard.h"
|
||||
|
||||
class nsIPref;
|
||||
|
||||
@ -59,15 +61,18 @@ public:
|
||||
nsresult IsDomainExcluded(const char *address, nsIPref *pPref, PRBool *bExclude);
|
||||
nsresult SetNamesForCard(nsIAbCard *senderCard, const char *fullName);
|
||||
nsresult SplitFullName (const char *fullName, char **firstName, char **lastName);
|
||||
nsresult Init();
|
||||
|
||||
private:
|
||||
static int PR_CALLBACK collectEmailAddressEnableSizeLimitPrefChanged(const char *newpref, void *data);
|
||||
static int PR_CALLBACK collectEmailAddressSizeLimitPrefChanged(const char *newpref, void *data);
|
||||
void setupPrefs(void);
|
||||
nsresult AddCardToCollectedAddressBook(nsIAbCard *card);
|
||||
|
||||
protected:
|
||||
nsCOMPtr <nsIAddrDatabase> m_historyAB;
|
||||
nsCOMPtr <nsIAbDirectory> m_historyDirectory;
|
||||
PRInt32 maxCABsize;
|
||||
PRInt32 sizeLimitEnabled;
|
||||
PRInt32 m_maxCABsize;
|
||||
PRBool m_sizeLimitEnabled;
|
||||
|
||||
};
|
||||
|
||||
|
@ -52,20 +52,12 @@
|
||||
#include "nsIPref.h"
|
||||
#include "prmem.h"
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kAutoCompleteResultsCID, NS_AUTOCOMPLETERESULTS_CID);
|
||||
static NS_DEFINE_CID(kAutoCompleteItemCID, NS_AUTOCOMPLETEITEM_CID);
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsAbAutoCompleteSession, nsIAbAutoCompleteSession, nsIAutoCompleteSession)
|
||||
|
||||
nsAbAutoCompleteSession::nsAbAutoCompleteSession()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mParser = do_GetService(kHeaderParserCID);
|
||||
mParser = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID);
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +158,7 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr,
|
||||
if (!fullAddress.IsEmpty())
|
||||
{
|
||||
/* We need to convert back the result from UTF-8 to Unicode */
|
||||
INTL_ConvertToUnicode(fullAddress.get(), fullAddress.Length(), (void**)&fullAddrStr);
|
||||
fullAddrStr = nsCRT::strdup(NS_ConvertUTF8toUCS2(fullAddress.get()).get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,8 +190,7 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr,
|
||||
|
||||
if (fullAddrStr && ! ItsADuplicate(fullAddrStr, results))
|
||||
{
|
||||
nsCOMPtr<nsIAutoCompleteItem> newItem;
|
||||
rv = nsComponentManager::CreateInstance(kAutoCompleteItemCID, nsnull, NS_GET_IID(nsIAutoCompleteItem), getter_AddRefs(newItem));
|
||||
nsCOMPtr<nsIAutoCompleteItem> newItem = do_CreateInstance(NS_AUTOCOMPLETEITEM_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsAbAutoCompleteParam *param = new nsAbAutoCompleteParam(pNickNameStr, pDisplayNameStr, pFirstNameStr, pLastNameStr, pEmailStr, pNotesStr, pDirName, bIsMailList, type);
|
||||
@ -253,7 +244,7 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr,
|
||||
|
||||
static PRBool CommonPrefix(const PRUnichar *aString, const PRUnichar *aSubstr, PRInt32 aSubstrLen)
|
||||
{
|
||||
if (aSubstrLen == 0 || nsCRT::strlen(aString) < aSubstrLen)
|
||||
if (!aSubstrLen || (nsCRT::strlen(aString) < NS_STATIC_CAST(PRUint32, aSubstrLen)))
|
||||
return PR_FALSE;
|
||||
|
||||
return (Compare(Substring(aString, aString+aSubstrLen),
|
||||
@ -480,23 +471,21 @@ nsresult nsAbAutoCompleteSession::SearchCards(nsIAbDirectory* directory, nsAbAut
|
||||
}
|
||||
|
||||
|
||||
nsresult nsAbAutoCompleteSession::SearchDirectory(nsString& fileName, nsAbAutoCompleteSearchString* searchStr, nsIAutoCompleteResults* results, PRBool searchSubDirectory)
|
||||
nsresult nsAbAutoCompleteSession::SearchDirectory(const char *fileName, nsAbAutoCompleteSearchString* searchStr, nsIAutoCompleteResults* results, PRBool searchSubDirectory)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv));
|
||||
nsCOMPtr<nsIRDFService> rdfService(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr <nsIRDFResource> resource;
|
||||
char * strFileName = ToNewCString(fileName);
|
||||
rv = rdfService->GetResource(strFileName, getter_AddRefs(resource));
|
||||
Recycle(strFileName);
|
||||
rv = rdfService->GetResource(fileName, getter_AddRefs(resource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// query interface
|
||||
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(resource, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!fileName.EqualsWithConversion(kAllDirectoryRoot))
|
||||
if (nsCRT::strcmp(kAllDirectoryRoot, fileName))
|
||||
rv = SearchCards(directory, searchStr, results);
|
||||
|
||||
if (!searchSubDirectory)
|
||||
@ -520,9 +509,7 @@ nsresult nsAbAutoCompleteSession::SearchDirectory(nsString& fileName, nsAbAutoCo
|
||||
{
|
||||
nsXPIDLCString URI;
|
||||
subResource->GetValue(getter_Copies(URI));
|
||||
nsAutoString subURI;
|
||||
subURI.AssignWithConversion(URI);
|
||||
rv = SearchDirectory(subURI, searchStr, results, PR_TRUE);
|
||||
rv = SearchDirectory(URI.get(), searchStr, results, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -603,7 +590,7 @@ NS_IMETHODIMP nsAbAutoCompleteSession::OnStartLookup(const PRUnichar *uSearchStr
|
||||
|
||||
PRBool enableAutocomplete = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
pPref->GetBoolPref("mail.enable_autocomplete", &enableAutocomplete);
|
||||
@ -634,13 +621,11 @@ NS_IMETHODIMP nsAbAutoCompleteSession::OnStartLookup(const PRUnichar *uSearchStr
|
||||
nsAbAutoCompleteSearchString searchStrings(uSearchString);
|
||||
|
||||
ResetMatchTypeConters();
|
||||
nsCOMPtr<nsIAutoCompleteResults> results;
|
||||
rv = nsComponentManager::CreateInstance(kAutoCompleteResultsCID, nsnull, NS_GET_IID(nsIAutoCompleteResults), getter_AddRefs(results));
|
||||
nsCOMPtr<nsIAutoCompleteResults> results = do_CreateInstance(NS_AUTOCOMPLETERESULTS_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_FAILED(SearchPreviousResults(&searchStrings, previousSearchResult, results)))
|
||||
{
|
||||
nsAutoString root; root.AssignWithConversion(kAllDirectoryRoot);
|
||||
rv = SearchDirectory(root, &searchStrings, results, PR_TRUE);
|
||||
rv = SearchDirectory(kAllDirectoryRoot, &searchStrings, results, PR_TRUE);
|
||||
}
|
||||
|
||||
AutoCompleteStatus status = nsIAutoCompleteStatus::failed;
|
||||
|
@ -107,7 +107,7 @@ protected:
|
||||
PRBool CheckEntry(nsAbAutoCompleteSearchString* searchStr, const PRUnichar* nickName,const PRUnichar* displayName,
|
||||
const PRUnichar* firstName, const PRUnichar* lastName, const PRUnichar* emailAddress, MatchType* matchType);
|
||||
nsresult SearchCards(nsIAbDirectory* directory, nsAbAutoCompleteSearchString* searchStr, nsIAutoCompleteResults* results);
|
||||
nsresult SearchDirectory(nsString& fileName, nsAbAutoCompleteSearchString* searchStr, nsIAutoCompleteResults* results, PRBool searchSubDirectory = PR_FALSE);
|
||||
nsresult SearchDirectory(const char *fileName, nsAbAutoCompleteSearchString* searchStr, nsIAutoCompleteResults* results, PRBool searchSubDirectory = PR_FALSE);
|
||||
nsresult SearchPreviousResults(nsAbAutoCompleteSearchString *uSearchString, nsIAutoCompleteResults *previousSearchResult, nsIAutoCompleteResults* results);
|
||||
|
||||
nsCOMPtr<nsIMsgHeaderParser> mParser;
|
||||
|
@ -58,15 +58,6 @@
|
||||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kAddrBookCID, NS_ADDRESSBOOK_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDBCID, NS_ADDRDATABASE_CID);
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
static NS_DEFINE_CID(kMessengerMigratorCID, NS_MESSENGERMIGRATOR_CID);
|
||||
|
||||
const char* kDescriptionPropertyName = "description";
|
||||
const char* kFileNamePropertyName = "filename";
|
||||
const char* kURIPropertyName = "uri";
|
||||
@ -99,7 +90,7 @@ nsresult nsAbBSDirectory::NotifyItemAdded(nsISupports *item)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->NotifyDirectoryItemAdded(this, item);
|
||||
return NS_OK;
|
||||
@ -109,9 +100,10 @@ nsresult nsAbBSDirectory::NotifyItemDeleted(nsISupports *item)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->NotifyDirectoryItemDeleted(this, item);
|
||||
abSession->NotifyDirectoryDeleted(this, item);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -114,32 +114,6 @@ NS_IMETHODIMP nsAbBooleanConditionString::SetValue(const PRUnichar * aValue)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsAbBooleanConditionString::Create(nsISupports* aOuter, REFNSIID aIID, void* *aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsAbBooleanConditionString* it = new nsAbBooleanConditionString ();
|
||||
if (it == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_IF_ADDREF(it);
|
||||
nsresult rv = it->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(it);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult NS_NewIAbBooleanConditionString(nsIAbBooleanConditionString** aInstancePtrResult)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsAbBooleanConditionString::Create(NULL, NS_GET_IID(nsIAbBooleanConditionString), NS_REINTERPRET_CAST(void**,aInstancePtrResult));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbBooleanExpression, nsIAbBooleanExpression)
|
||||
|
||||
nsAbBooleanExpression::nsAbBooleanExpression() :
|
||||
@ -178,13 +152,10 @@ NS_IMETHODIMP nsAbBooleanExpression::GetExpressions(nsISupportsArray** aExpressi
|
||||
if (!mExpressions)
|
||||
NS_NewISupportsArray(getter_AddRefs(mExpressions));
|
||||
|
||||
*aExpressions = mExpressions;
|
||||
NS_IF_ADDREF(*aExpressions);
|
||||
|
||||
NS_IF_ADDREF(*aExpressions = mExpressions);
|
||||
return NS_OK;
|
||||
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbBooleanExpression::SetExpressions(nsISupportsArray* aExpressions)
|
||||
{
|
||||
if (!aExpressions)
|
||||
@ -207,25 +178,3 @@ NS_IMETHODIMP nsAbBooleanExpression::AgetExpressions(PRUint32 *aExpressionsSize,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD nsAbBooleanExpression::Create(nsISupports* aOuter, REFNSIID aIID, void* *aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsAbBooleanExpression* it = new nsAbBooleanExpression();
|
||||
if (it == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_IF_ADDREF(it);
|
||||
nsresult rv = it->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(it);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult NS_NewIAbBooleanExpression(nsIAbBooleanExpression** aInstancePtrResult)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsAbBooleanExpression::Create(NULL, NS_GET_IID(nsIAbBooleanExpression), NS_REINTERPRET_CAST(void**, aInstancePtrResult));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,6 @@ public:
|
||||
nsAbBooleanConditionString();
|
||||
virtual ~nsAbBooleanConditionString();
|
||||
|
||||
static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
protected:
|
||||
nsAbBooleanConditionType mCondition;
|
||||
nsCString mName;
|
||||
@ -69,16 +67,9 @@ public:
|
||||
nsAbBooleanExpression();
|
||||
virtual ~nsAbBooleanExpression();
|
||||
|
||||
static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
protected:
|
||||
nsAbBooleanOperationType mOperation;
|
||||
nsCOMPtr<nsISupportsArray> mExpressions;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewIAbBooleanConditionString(nsIAbBooleanConditionString** aInstancePtrResult);
|
||||
|
||||
nsresult
|
||||
NS_NewIAbBooleanExpression(nsIAbBooleanExpression** aInstancePtrResult);
|
||||
|
||||
#endif
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
@ -49,12 +50,8 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsIAbDirectory.h"
|
||||
#include "nsIAddressBook.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
nsAbCardProperty::nsAbCardProperty(void)
|
||||
{
|
||||
@ -63,33 +60,16 @@ nsAbCardProperty::nsAbCardProperty(void)
|
||||
m_LastModDate = 0;
|
||||
|
||||
m_PreferMailFormat = nsIAbPreferMailFormat::unknown;
|
||||
m_bIsMailList = PR_FALSE;
|
||||
m_MailListURI = 0;
|
||||
|
||||
|
||||
m_IsMailList = PR_FALSE;
|
||||
m_MailListURI = nsnull;
|
||||
}
|
||||
|
||||
nsAbCardProperty::~nsAbCardProperty(void)
|
||||
{
|
||||
PR_FREEIF(m_MailListURI);
|
||||
CRTFREEIF(m_MailListURI);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAbCardProperty)
|
||||
NS_IMPL_RELEASE(nsAbCardProperty)
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIAbCard)) ||
|
||||
aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aResult = NS_STATIC_CAST(nsIAbCard*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
NS_IMPL_ISUPPORTS1(nsAbCardProperty, nsIAbCard)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -129,13 +109,13 @@ NS_IMETHODIMP nsAbCardProperty::SetPreferMailFormat(PRUint32 aFormat)
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetIsMailList(PRBool *aIsMailList)
|
||||
{
|
||||
*aIsMailList = m_bIsMailList;
|
||||
*aIsMailList = m_IsMailList;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetIsMailList(PRBool aIsMailList)
|
||||
{
|
||||
m_bIsMailList = aIsMailList;
|
||||
m_IsMailList = aIsMailList;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -168,201 +148,408 @@ NS_IMETHODIMP nsAbCardProperty::SetMailListURI(const char *aMailListURI)
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetCardValue(const char *attrname, PRUnichar **value)
|
||||
{
|
||||
if (!PL_strcmp(attrname, kFirstNameColumn))
|
||||
GetFirstName(value);
|
||||
else if (!PL_strcmp(attrname, kLastNameColumn))
|
||||
GetLastName(value);
|
||||
else if (!PL_strcmp(attrname, kDisplayNameColumn))
|
||||
GetDisplayName(value);
|
||||
else if (!PL_strcmp(attrname, kNicknameColumn))
|
||||
GetNickName(value);
|
||||
else if (!PL_strcmp(attrname, kPriEmailColumn))
|
||||
GetPrimaryEmail(value);
|
||||
else if (!PL_strcmp(attrname, k2ndEmailColumn))
|
||||
GetSecondEmail(value);
|
||||
else if (!PL_strcmp(attrname, kWorkPhoneColumn))
|
||||
GetWorkPhone(value);
|
||||
else if (!PL_strcmp(attrname, kHomePhoneColumn))
|
||||
GetHomePhone(value);
|
||||
else if (!PL_strcmp(attrname, kDepartmentColumn))
|
||||
GetDepartment(value);
|
||||
else if (!PL_strcmp(attrname, kCompanyColumn))
|
||||
GetCompany(value);
|
||||
else if (!PL_strcmp(attrname, kJobTitleColumn))
|
||||
GetJobTitle(value);
|
||||
else if (!PL_strcmp(attrname, kFaxColumn))
|
||||
GetFaxNumber(value);
|
||||
else if (!PL_strcmp(attrname, kPagerColumn))
|
||||
GetPagerNumber(value);
|
||||
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 if (!PL_strcmp(attrname, kPreferMailFormatColumn))
|
||||
{
|
||||
PRUint32 format = nsIAbPreferMailFormat::unknown;
|
||||
GetPreferMailFormat(&format);
|
||||
nsString formatStr;
|
||||
switch (format) {
|
||||
case nsIAbPreferMailFormat::unknown :
|
||||
formatStr.Assign(NS_LITERAL_STRING("unknown"));
|
||||
NS_ENSURE_ARG_POINTER(attrname);
|
||||
NS_ENSURE_ARG_POINTER(value);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
switch (attrname[0]) {
|
||||
case 'A':
|
||||
// kAddressCharSetColumn?
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
case 'B':
|
||||
// BirthYear, BirthMonth, BirthDay
|
||||
switch (attrname[5]) {
|
||||
case 'Y':
|
||||
rv = GetBirthYear(value);
|
||||
break;
|
||||
case 'M':
|
||||
rv = GetBirthMonth(value);
|
||||
break;
|
||||
case 'D':
|
||||
rv = GetBirthDay(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
switch (attrname[1]) {
|
||||
case 'o':
|
||||
rv = GetCompany(value);
|
||||
break;
|
||||
case 'e':
|
||||
rv = GetCellularNumber(value);
|
||||
break;
|
||||
case 'u':
|
||||
switch (attrname[6]) {
|
||||
case '1':
|
||||
rv = GetCustom1(value);
|
||||
break;
|
||||
case '2':
|
||||
rv = GetCustom2(value);
|
||||
break;
|
||||
case '3':
|
||||
rv = GetCustom3(value);
|
||||
break;
|
||||
case '4':
|
||||
rv = GetCustom4(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
if (attrname[1] == 'i')
|
||||
rv = GetDisplayName(value);
|
||||
else
|
||||
rv = GetDepartment(value);
|
||||
break;
|
||||
case 'F':
|
||||
if (attrname[1] == 'i')
|
||||
rv = GetFirstName(value);
|
||||
else
|
||||
rv = GetFaxNumber(value);
|
||||
break;
|
||||
case 'H':
|
||||
switch (attrname[4]) {
|
||||
case 'A':
|
||||
if (attrname[11] == '\0')
|
||||
rv = GetHomeAddress(value);
|
||||
else
|
||||
rv = GetHomeAddress2(value);
|
||||
break;
|
||||
case 'C':
|
||||
if (attrname[5] == 'i')
|
||||
rv = GetHomeCity(value);
|
||||
else
|
||||
rv = GetHomeCountry(value);
|
||||
break;
|
||||
case 'P':
|
||||
rv = GetHomePhone(value);
|
||||
break;
|
||||
case 'S':
|
||||
rv = GetHomeState(value);
|
||||
break;
|
||||
case 'Z':
|
||||
rv = GetHomeZipCode(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'J':
|
||||
rv = GetJobTitle(value);
|
||||
break;
|
||||
case 'L':
|
||||
if (attrname[1] == 'a') {
|
||||
if (attrname[4] == 'N')
|
||||
rv = GetLastName(value);
|
||||
else {
|
||||
// XXX todo
|
||||
// fix me? LDAP code gets here
|
||||
PRUint32 lastModifiedDate;
|
||||
rv = GetLastModifiedDate(&lastModifiedDate);
|
||||
*value = nsCRT::strdup(NS_LITERAL_STRING("0Z").get());
|
||||
}
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
case 'N':
|
||||
if (attrname[1] == 'o')
|
||||
rv = GetNotes(value);
|
||||
else
|
||||
rv = GetNickName(value);
|
||||
break;
|
||||
case 'P':
|
||||
switch (attrname[2]) {
|
||||
case 'e':
|
||||
PRUint32 format;
|
||||
rv = GetPreferMailFormat(&format);
|
||||
const PRUnichar *formatStr;
|
||||
|
||||
switch (format) {
|
||||
case nsIAbPreferMailFormat::html:
|
||||
formatStr = NS_LITERAL_STRING("html").get();
|
||||
break;
|
||||
case nsIAbPreferMailFormat::plaintext :
|
||||
formatStr = NS_LITERAL_STRING("plaintext").get();
|
||||
break;
|
||||
case nsIAbPreferMailFormat::unknown:
|
||||
default :
|
||||
formatStr = NS_LITERAL_STRING("unknown").get();
|
||||
break;
|
||||
}
|
||||
*value = nsCRT::strdup(formatStr);
|
||||
break;
|
||||
case 'g':
|
||||
rv = GetPagerNumber(value);
|
||||
break;
|
||||
case 'i':
|
||||
rv = GetPrimaryEmail(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
rv = GetSecondEmail(value);
|
||||
break;
|
||||
case 'W':
|
||||
if (attrname[1] == 'e') {
|
||||
if (attrname[7] == '1')
|
||||
rv = GetWebPage1(value);
|
||||
else
|
||||
rv = GetWebPage2(value);
|
||||
}
|
||||
else {
|
||||
switch (attrname[4]) {
|
||||
case 'A':
|
||||
if (attrname[11] == '\0')
|
||||
rv = GetWorkAddress(value);
|
||||
else
|
||||
rv = GetWorkAddress2(value);
|
||||
break;
|
||||
case nsIAbPreferMailFormat::plaintext :
|
||||
formatStr.Assign(NS_LITERAL_STRING("plaintext"));
|
||||
case 'C':
|
||||
if (attrname[5] == 'i')
|
||||
rv = GetWorkCity(value);
|
||||
else
|
||||
rv = GetWorkCountry(value);
|
||||
break;
|
||||
case nsIAbPreferMailFormat::html :
|
||||
formatStr.Assign(NS_LITERAL_STRING("html"));
|
||||
case 'P':
|
||||
rv = GetWorkPhone(value);
|
||||
break;
|
||||
default :
|
||||
formatStr.Assign(NS_LITERAL_STRING("unknown"));
|
||||
case 'S':
|
||||
rv = GetWorkState(value);
|
||||
break;
|
||||
case 'Z':
|
||||
rv = GetWorkZipCode(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
*value = ToNewUnicode(formatStr);
|
||||
}
|
||||
|
||||
/* else handle pass down attribute */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetCardValue(const char *attrname, const PRUnichar *value)
|
||||
{
|
||||
if (!attrname && !value)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
NS_ENSURE_ARG_POINTER(attrname);
|
||||
NS_ENSURE_ARG_POINTER(value);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!PL_strcmp(attrname, kFirstNameColumn))
|
||||
rv = SetFirstName((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kLastNameColumn))
|
||||
rv = SetLastName((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kDisplayNameColumn))
|
||||
rv = SetDisplayName((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kNicknameColumn))
|
||||
rv = SetNickName((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kPriEmailColumn))
|
||||
rv = SetPrimaryEmail((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, k2ndEmailColumn))
|
||||
rv = SetSecondEmail((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWorkPhoneColumn))
|
||||
rv = SetWorkPhone((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kHomePhoneColumn))
|
||||
rv = SetHomePhone((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kFaxColumn))
|
||||
rv = SetFaxNumber((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kPagerColumn))
|
||||
rv = SetPagerNumber((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kCellularColumn))
|
||||
rv = SetCellularNumber((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kHomeAddressColumn))
|
||||
rv = SetHomeAddress((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kHomeAddress2Column))
|
||||
rv = SetHomeAddress2((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kHomeCityColumn))
|
||||
rv = SetHomeCity((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kHomeStateColumn))
|
||||
rv = SetHomeState((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kHomeZipCodeColumn))
|
||||
rv = SetHomeZipCode((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kHomeCountryColumn))
|
||||
rv = SetHomeCountry((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWorkAddressColumn))
|
||||
rv = SetWorkAddress((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWorkAddress2Column))
|
||||
rv = SetWorkAddress2((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWorkCityColumn))
|
||||
rv = SetWorkCity((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWorkStateColumn))
|
||||
rv = SetWorkState((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWorkZipCodeColumn))
|
||||
rv = SetWorkZipCode((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWorkCountryColumn))
|
||||
rv = SetWorkCountry((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWebPage1Column))
|
||||
rv = SetWebPage1((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kWebPage2Column))
|
||||
rv = SetWebPage2((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kBirthYearColumn))
|
||||
rv = SetBirthYear((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kBirthMonthColumn))
|
||||
rv = SetBirthMonth((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kBirthDayColumn))
|
||||
rv = SetBirthDay((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kCustom1Column))
|
||||
rv = SetCustom1((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kCustom2Column))
|
||||
rv = SetCustom2((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kCustom3Column))
|
||||
rv = SetCustom3((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kCustom4Column))
|
||||
rv = SetCustom4((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kNotesColumn))
|
||||
rv = SetNotes((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kDepartmentColumn))
|
||||
rv = SetDepartment((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kCompanyColumn))
|
||||
rv = SetCompany((PRUnichar *)value);
|
||||
else if (!PL_strcmp(attrname, kPreferMailFormatColumn))
|
||||
{
|
||||
PRUint32 format = nsIAbPreferMailFormat::unknown;
|
||||
nsString formatStr(value);
|
||||
if (Compare(formatStr, NS_LITERAL_STRING("unknown"), nsCaseInsensitiveStringComparator()))
|
||||
format = nsIAbPreferMailFormat::unknown;
|
||||
if (Compare(formatStr, NS_LITERAL_STRING("plaintext"), nsCaseInsensitiveStringComparator()))
|
||||
format = nsIAbPreferMailFormat::plaintext;
|
||||
if (Compare(formatStr, NS_LITERAL_STRING("html"), nsCaseInsensitiveStringComparator()))
|
||||
format = nsIAbPreferMailFormat::html;
|
||||
SetPreferMailFormat(format);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
switch (attrname[0]) {
|
||||
case 'A':
|
||||
// kAddressCharSetColumn?
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
case 'B':
|
||||
// BirthYear, BirthMonth, BirthDay
|
||||
switch (attrname[5]) {
|
||||
case 'Y':
|
||||
rv = SetBirthYear(value);
|
||||
break;
|
||||
case 'M':
|
||||
rv = SetBirthMonth(value);
|
||||
break;
|
||||
case 'D':
|
||||
rv = SetBirthDay(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
switch (attrname[1]) {
|
||||
case 'o':
|
||||
rv = SetCompany(value);
|
||||
break;
|
||||
case 'e':
|
||||
rv = SetCellularNumber(value);
|
||||
break;
|
||||
case 'u':
|
||||
switch (attrname[6]) {
|
||||
case '1':
|
||||
rv = SetCustom1(value);
|
||||
break;
|
||||
case '2':
|
||||
rv = SetCustom2(value);
|
||||
break;
|
||||
case '3':
|
||||
rv = SetCustom3(value);
|
||||
break;
|
||||
case '4':
|
||||
rv = SetCustom4(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
if (attrname[1] == 'i')
|
||||
rv = SetDisplayName(value);
|
||||
else
|
||||
rv = SetDepartment(value);
|
||||
break;
|
||||
case 'F':
|
||||
if (attrname[1] == 'i')
|
||||
rv = SetFirstName(value);
|
||||
else
|
||||
rv = SetFaxNumber(value);
|
||||
break;
|
||||
case 'H':
|
||||
switch (attrname[4]) {
|
||||
case 'A':
|
||||
if (attrname[11] == '\0')
|
||||
rv = SetHomeAddress(value);
|
||||
else
|
||||
rv = SetHomeAddress2(value);
|
||||
break;
|
||||
case 'C':
|
||||
if (attrname[5] == 'i')
|
||||
rv = SetHomeCity(value);
|
||||
else
|
||||
rv = SetHomeCountry(value);
|
||||
break;
|
||||
case 'P':
|
||||
rv = SetHomePhone(value);
|
||||
break;
|
||||
case 'S':
|
||||
rv = SetHomeState(value);
|
||||
break;
|
||||
case 'Z':
|
||||
rv = SetHomeZipCode(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'J':
|
||||
rv = SetJobTitle(value);
|
||||
break;
|
||||
case 'L':
|
||||
if (attrname[1] == 'a') {
|
||||
if (attrname[4] == 'N')
|
||||
rv = SetLastName(value);
|
||||
else {
|
||||
// XXX todo
|
||||
// fix me? LDAP code gets here
|
||||
rv = SetLastModifiedDate(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
case 'N':
|
||||
if (attrname[1] == 'o')
|
||||
rv = SetNotes(value);
|
||||
else
|
||||
rv = SetNickName(value);
|
||||
break;
|
||||
case 'P':
|
||||
switch (attrname[2]) {
|
||||
case 'e':
|
||||
switch (value[0]) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
rv = SetPreferMailFormat(nsIAbPreferMailFormat::html);
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
rv = SetPreferMailFormat(nsIAbPreferMailFormat::plaintext);
|
||||
break;
|
||||
default:
|
||||
rv = SetPreferMailFormat(nsIAbPreferMailFormat::unknown);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
rv = SetPagerNumber(value);
|
||||
break;
|
||||
case 'i':
|
||||
rv = SetPrimaryEmail(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
rv = SetSecondEmail(value);
|
||||
break;
|
||||
case 'W':
|
||||
if (attrname[1] == 'e') {
|
||||
if (attrname[7] == '1')
|
||||
rv = SetWebPage1(value);
|
||||
else
|
||||
rv = SetWebPage2(value);
|
||||
}
|
||||
else {
|
||||
switch (attrname[4]) {
|
||||
case 'A':
|
||||
if (attrname[11] == '\0')
|
||||
rv = SetWorkAddress(value);
|
||||
else
|
||||
rv = SetWorkAddress2(value);
|
||||
break;
|
||||
case 'C':
|
||||
if (attrname[5] == 'i')
|
||||
rv = SetWorkCity(value);
|
||||
else
|
||||
rv = SetWorkCountry(value);
|
||||
break;
|
||||
case 'P':
|
||||
rv = SetWorkPhone(value);
|
||||
break;
|
||||
case 'S':
|
||||
rv = SetWorkState(value);
|
||||
break;
|
||||
case 'Z':
|
||||
rv = SetWorkZipCode(value);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbCardProperty::GetFirstName(PRUnichar * *aFirstName)
|
||||
{ return GetAttributeName(aFirstName, m_FirstName); }
|
||||
@ -659,79 +846,6 @@ NS_IMETHODIMP
|
||||
nsAbCardProperty::SetLastModifiedDate(PRUint32 aLastModifiedDate)
|
||||
{ return m_LastModDate = aLastModifiedDate; }
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbCardProperty::SetName(const PRUnichar * aName)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsAbCardProperty::GetName(PRUnichar * *aName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
// get name depend on "mail.addr_book.lastnamefirst"
|
||||
// 0= displayname, 1= lastname first, 2=firstname first
|
||||
nsCOMPtr<nsIPref> pPref = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 lastNameFirst = 0;
|
||||
rv = pPref->GetIntPref("mail.addr_book.lastnamefirst", &lastNameFirst);
|
||||
if (lastNameFirst == 0)
|
||||
GetDisplayName(aName);
|
||||
else
|
||||
{
|
||||
if (aName)
|
||||
{
|
||||
nsString name;
|
||||
nsString firstName;
|
||||
nsString lastName;
|
||||
nsXPIDLString str;
|
||||
GetFirstName(getter_Copies(str));
|
||||
if (str)
|
||||
{
|
||||
firstName = str;
|
||||
}
|
||||
GetLastName(getter_Copies(str));
|
||||
if (str)
|
||||
{
|
||||
lastName = str;
|
||||
}
|
||||
|
||||
if (lastName.Length() == 0)
|
||||
name = firstName;
|
||||
else if (firstName.Length() == 0)
|
||||
name = lastName;
|
||||
else
|
||||
{
|
||||
if (lastNameFirst == 1)
|
||||
{
|
||||
name = lastName;
|
||||
name.Append(NS_LITERAL_STRING(", "));
|
||||
name += firstName;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = firstName;
|
||||
name.Append(NS_LITERAL_STRING(" "));
|
||||
name += lastName;
|
||||
}
|
||||
}
|
||||
|
||||
*aName = ToNewUnicode(name);
|
||||
if (!(*aName))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::Copy(nsIAbCard* srcCard)
|
||||
{
|
||||
nsXPIDLString str;
|
||||
@ -749,7 +863,7 @@ NS_IMETHODIMP nsAbCardProperty::Copy(nsIAbCard* srcCard)
|
||||
srcCard->GetSecondEmail(getter_Copies(str));
|
||||
SetSecondEmail(str);
|
||||
|
||||
PRUint32 format = nsIAbPreferMailFormat::unknown;
|
||||
PRUint32 format;
|
||||
srcCard->GetPreferMailFormat(&format);
|
||||
SetPreferMailFormat(format);
|
||||
|
||||
@ -817,73 +931,13 @@ NS_IMETHODIMP nsAbCardProperty::Copy(nsIAbCard* srcCard)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::AddCardToDatabase(const char *uri, nsIAbCard **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> res;
|
||||
rv = rdf->GetResource(uri, getter_AddRefs(res));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(res, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbCard> cardInstance;
|
||||
rv = directory->AddCard (this, getter_AddRefs (cardInstance));
|
||||
|
||||
*_retval = cardInstance;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::DropCardToDatabase(const char *uri, nsIAbCard **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> res;
|
||||
rv = rdf->GetResource(uri, getter_AddRefs(res));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(res, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbCard> cardInstance;
|
||||
rv = directory->DropCard (this, getter_AddRefs (cardInstance));
|
||||
|
||||
*_retval = cardInstance;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetCollationKey(const PRUnichar *str, PRUnichar **key)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!addressBook)
|
||||
{
|
||||
// Keep a local copy of the addressBook service
|
||||
// for performance reasons
|
||||
addressBook = do_GetService (NS_ADDRESSBOOK_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = addressBook->CreateCollationKey(str, key);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// nsIAbCard NOT IMPLEMENTED methods
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::EditCardToDatabase(const char *uri)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetPrintCardUrl(char * *aPrintCardUrl)
|
||||
NS_IMETHODIMP nsAbCardProperty::Equals(nsIAbCard *card, PRBool *result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*result = (card == this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAddressBook.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
|
||||
/*
|
||||
* Address Book Card Property
|
||||
@ -107,13 +106,10 @@ protected:
|
||||
nsString m_Custom4;
|
||||
nsString m_Note;
|
||||
PRUint32 m_LastModDate;
|
||||
PRUint32 m_Key;
|
||||
PRUint32 m_PreferMailFormat;
|
||||
|
||||
PRBool m_bIsMailList;
|
||||
PRBool m_IsMailList;
|
||||
char* m_MailListURI;
|
||||
|
||||
nsCOMPtr<nsIAddressBook> addressBook;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -54,38 +54,19 @@
|
||||
#include "prprf.h"
|
||||
#include "prmem.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
nsAbDirProperty::nsAbDirProperty(void)
|
||||
: m_LastModifiedDate(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
m_bIsMailList = PR_FALSE;
|
||||
m_IsMailList = PR_FALSE;
|
||||
}
|
||||
|
||||
nsAbDirProperty::~nsAbDirProperty(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAbDirProperty)
|
||||
NS_IMPL_RELEASE(nsAbDirProperty)
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIAbDirectory)) ||
|
||||
aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aResult = NS_STATIC_CAST(nsIAbDirectory*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
NS_IMPL_ISUPPORTS1(nsAbDirProperty,nsIAbDirectory)
|
||||
|
||||
/* readonly attribute long operations; */
|
||||
NS_IMETHODIMP nsAbDirProperty::GetOperations(PRInt32 *aOperations)
|
||||
@ -166,12 +147,6 @@ nsresult nsAbDirProperty::SetAttributeName(const PRUnichar *aName, nsString& arr
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetListName(PRUnichar * *aListName)
|
||||
{ return GetAttributeName(aListName, m_ListName); }
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetListName(const PRUnichar * aListName)
|
||||
{ return SetAttributeName(aListName, m_ListName); }
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetListNickName(PRUnichar * *aListNickName)
|
||||
{ return GetAttributeName(aListNickName, m_ListNickName); }
|
||||
|
||||
@ -186,13 +161,13 @@ NS_IMETHODIMP nsAbDirProperty::SetDescription(const PRUnichar * aDescription)
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetIsMailList(PRBool *aIsMailList)
|
||||
{
|
||||
*aIsMailList = m_bIsMailList;
|
||||
*aIsMailList = m_IsMailList;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetIsMailList(PRBool aIsMailList)
|
||||
{
|
||||
m_bIsMailList = aIsMailList;
|
||||
m_IsMailList = aIsMailList;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -217,7 +192,7 @@ NS_IMETHODIMP nsAbDirProperty::SetAddressLists(nsISupportsArray * aAddressLists)
|
||||
NS_IMETHODIMP nsAbDirProperty::AddMailListToDatabase(const char *uri)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
|
||||
nsCOMPtr<nsIRDFService> rdf(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> res;
|
||||
@ -228,15 +203,15 @@ NS_IMETHODIMP nsAbDirProperty::AddMailListToDatabase(const char *uri)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = directory->AddMailList(this);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::CopyMailList(nsIAbDirectory* srcList)
|
||||
{
|
||||
nsXPIDLString str;
|
||||
srcList->GetListName(getter_Copies(str));
|
||||
SetListName(str);
|
||||
srcList->GetDirName(getter_Copies(str));
|
||||
SetDirName(str);
|
||||
srcList->GetListNickName(getter_Copies(str));
|
||||
SetListNickName(str);
|
||||
srcList->GetDescription(getter_Copies(str));
|
||||
@ -244,21 +219,12 @@ NS_IMETHODIMP nsAbDirProperty::CopyMailList(nsIAbDirectory* srcList)
|
||||
|
||||
SetIsMailList(PR_TRUE);
|
||||
|
||||
nsISupportsArray* pAddressLists;
|
||||
srcList->GetAddressLists(&pAddressLists);
|
||||
NS_IF_ADDREF(pAddressLists);
|
||||
nsCOMPtr <nsISupportsArray> pAddressLists;
|
||||
srcList->GetAddressLists(getter_AddRefs(pAddressLists));
|
||||
SetAddressLists(pAddressLists);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// nsIAbDirectory NOT IMPLEMENTED methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -295,14 +261,33 @@ NS_IMETHODIMP nsAbDirProperty::CreateDirectoryByURI(const PRUnichar *dirName, co
|
||||
NS_IMETHODIMP nsAbDirProperty::AddMailList(nsIAbDirectory *list)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::EditMailListToDatabase(const char *uri)
|
||||
NS_IMETHODIMP nsAbDirProperty::EditMailListToDatabase(const char *uri, nsIAbCard *listCard)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::AddCard(nsIAbCard *childCard, nsIAbCard **_retval)
|
||||
NS_IMETHODIMP nsAbDirProperty::AddCard(nsIAbCard *childCard, nsIAbCard **addedCard)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::DropCard(nsIAbCard *childCard, nsIAbCard **_retval)
|
||||
NS_IMETHODIMP nsAbDirProperty::DropCard(nsIAbCard *childCard, PRBool needToCopyCard)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetTotalCards(PRBool subDirectoryCount, PRUint32 *_retval)
|
||||
NS_IMETHODIMP nsAbDirProperty::GetValueForCard(nsIAbCard *card, const char *name, PRUnichar **value)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetValueForCard(nsIAbCard *card, const char *name, const PRUnichar *value)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetSupportsMailingLists(PRBool *aSupportsMailingsLists)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSupportsMailingsLists);
|
||||
*aSupportsMailingsLists = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetIsRemote(PRBool *aIsRemote)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsRemote);
|
||||
*aIsRemote = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -76,7 +77,7 @@ protected:
|
||||
nsString m_ListName;
|
||||
nsString m_ListNickName;
|
||||
nsString m_Description;
|
||||
PRBool m_bIsMailList;
|
||||
PRBool m_IsMailList;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> m_AddressList;
|
||||
|
||||
|
@ -90,13 +90,10 @@ NS_IMETHODIMP nsAbDirectoryQuerySimpleBooleanExpression::GetExpressions(nsISuppo
|
||||
if (!mExpressions)
|
||||
NS_NewISupportsArray(getter_AddRefs(mExpressions));
|
||||
|
||||
*aExpressions = mExpressions;
|
||||
NS_IF_ADDREF(*aExpressions);
|
||||
|
||||
NS_IF_ADDREF(*aExpressions = mExpressions);
|
||||
return NS_OK;
|
||||
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirectoryQuerySimpleBooleanExpression::SetExpressions(nsISupportsArray* aExpressions)
|
||||
{
|
||||
if (!aExpressions)
|
||||
@ -134,35 +131,6 @@ NS_IMETHODIMP nsAbDirectoryQuerySimpleBooleanExpression::AgetExpressions(PRUint3
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD nsAbDirectoryQuerySimpleBooleanExpression::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsAbDirectoryQuerySimpleBooleanExpression* it = new nsAbDirectoryQuerySimpleBooleanExpression ();
|
||||
if (it == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_IF_ADDREF(it);
|
||||
nsresult rv = it->QueryInterface(aIID, aResult);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_RELEASE(it);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult NS_NewAbDirectoryQuerySimpleBooleanExpression(nsIAbBooleanExpression** aInstancePtrResult)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsAbDirectoryQuerySimpleBooleanExpression::Create(NULL, NS_GET_IID(nsIAbBooleanExpression), NS_REINTERPRET_CAST(void**, aInstancePtrResult));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbDirectoryQueryArguments, nsIAbDirectoryQueryArguments)
|
||||
|
||||
nsAbDirectoryQueryArguments::nsAbDirectoryQueryArguments() :
|
||||
@ -181,16 +149,13 @@ NS_IMETHODIMP nsAbDirectoryQueryArguments::GetExpression(nsISupports** aExpressi
|
||||
if (!aExpression)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aExpression = mExpression;
|
||||
NS_IF_ADDREF(*aExpression);
|
||||
|
||||
NS_IF_ADDREF(*aExpression = mExpression);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirectoryQueryArguments::SetExpression(nsISupports* aExpression)
|
||||
{
|
||||
mExpression = aExpression;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -237,33 +202,6 @@ NS_IMETHODIMP nsAbDirectoryQueryArguments::GetReturnProperties(PRUint32* returnP
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD nsAbDirectoryQueryArguments::Create(nsISupports* aOuter, REFNSIID aIID, void* *aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsAbDirectoryQueryArguments* it = new nsAbDirectoryQueryArguments();
|
||||
if (it == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_IF_ADDREF(it);
|
||||
nsresult rv = it->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(it);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult NS_NewIAbDirectoryQueryArguments(nsIAbDirectoryQueryArguments** aInstancePtrResult)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsAbDirectoryQueryArguments::Create(NULL, NS_GET_IID(nsIAbDirectoryQueryArguments),
|
||||
NS_REINTERPRET_CAST(void**,aInstancePtrResult));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbDirectoryQueryPropertyValue, nsIAbDirectoryQueryPropertyValue)
|
||||
|
||||
nsAbDirectoryQueryPropertyValue::nsAbDirectoryQueryPropertyValue()
|
||||
@ -323,16 +261,10 @@ NS_IMETHODIMP nsAbDirectoryQueryPropertyValue::GetValueISupports(nsISupports* *
|
||||
if (!mValueISupports)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aValueISupports = mValueISupports;
|
||||
NS_IF_ADDREF(*aValueISupports);
|
||||
|
||||
NS_IF_ADDREF(*aValueISupports = mValueISupports);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbDirectoryQueryResult, nsIAbDirectoryQueryResult)
|
||||
|
||||
nsAbDirectoryQueryResult::nsAbDirectoryQueryResult() :
|
||||
@ -373,9 +305,7 @@ NS_IMETHODIMP nsAbDirectoryQueryResult::GetContextArgs(nsIAbDirectoryQueryArgume
|
||||
if (!mContextArgs)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aContextArgs = mContextArgs;
|
||||
NS_IF_ADDREF(*aContextArgs);
|
||||
|
||||
NS_IF_ADDREF(*aContextArgs = mContextArgs);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -393,9 +323,7 @@ NS_IMETHODIMP nsAbDirectoryQueryResult::GetResult(nsISupportsArray* *aResult)
|
||||
if (!mResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = mResult;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
NS_IF_ADDREF(*aResult = mResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -652,8 +580,7 @@ nsresult nsAbDirectoryQuery::matchCardCondition (nsIAbCard* card,
|
||||
rv = condition->GetName (getter_Copies (name));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (name.Equals ("card:URI") ||
|
||||
name.Equals ("card:nsIAbCard"))
|
||||
if (name.Equals ("card:nsIAbCard"))
|
||||
{
|
||||
if (conditionType == nsIAbBooleanConditionTypes::Exists)
|
||||
*matchFound = PR_TRUE;
|
||||
@ -754,29 +681,13 @@ nsresult nsAbDirectoryQuery::queryMatch (nsIAbCard* card,
|
||||
n.Assign (properties[i]);
|
||||
|
||||
nsAbDirectoryQueryPropertyValue* _propertyValue = 0;
|
||||
if (n.Equals(NS_LITERAL_CSTRING("card:nsIAbCard")))
|
||||
if (n.Equals("card:nsIAbCard"))
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports(do_QueryInterface(card, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
_propertyValue = new nsAbDirectoryQueryPropertyValue(n.get (), supports);
|
||||
if (_propertyValue == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else if (n.Equals(NS_LITERAL_CSTRING("card:URI")))
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> rdfResource(do_QueryInterface(card, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = rdfResource->GetValue (getter_Copies (uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString v;
|
||||
v.AssignWithConversion (uri.get ());
|
||||
|
||||
_propertyValue = new nsAbDirectoryQueryPropertyValue(n.get (), v.get ());
|
||||
if (_propertyValue == NULL)
|
||||
if (!_propertyValue)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
@ -789,7 +700,7 @@ nsresult nsAbDirectoryQuery::queryMatch (nsIAbCard* card,
|
||||
continue;
|
||||
|
||||
_propertyValue = new nsAbDirectoryQueryPropertyValue(n.get (), value.get ());
|
||||
if (_propertyValue == NULL)
|
||||
if (!_propertyValue)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -819,7 +730,7 @@ nsresult nsAbDirectoryQuery::queryMatch (nsIAbCard* card,
|
||||
arguments,
|
||||
nsIAbDirectoryQueryResult::queryResultMatch,
|
||||
propertyValues);
|
||||
if (_queryResult == NULL)
|
||||
if (!_queryResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
queryResult = _queryResult;
|
||||
|
||||
@ -835,7 +746,7 @@ nsresult nsAbDirectoryQuery::queryFinished (nsIAbDirectoryQueryArguments* argume
|
||||
arguments,
|
||||
nsIAbDirectoryQueryResult::queryResultComplete,
|
||||
0);
|
||||
if (_queryResult == NULL)
|
||||
if (!_queryResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
queryResult = _queryResult;
|
||||
|
||||
@ -850,7 +761,7 @@ nsresult nsAbDirectoryQuery::queryError (nsIAbDirectoryQueryArguments* arguments
|
||||
arguments,
|
||||
nsIAbDirectoryQueryResult::queryResultError,
|
||||
0);
|
||||
if (_queryResult == NULL)
|
||||
if (!_queryResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
queryResult = _queryResult;
|
||||
|
||||
|
@ -53,8 +53,6 @@ public:
|
||||
nsAbDirectoryQuerySimpleBooleanExpression();
|
||||
virtual ~nsAbDirectoryQuerySimpleBooleanExpression();
|
||||
|
||||
static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
public:
|
||||
nsCOMPtr<nsISupportsArray> mExpressions;
|
||||
nsAbBooleanOperationType mOperation;
|
||||
@ -70,8 +68,6 @@ public:
|
||||
nsAbDirectoryQueryArguments();
|
||||
virtual ~nsAbDirectoryQueryArguments();
|
||||
|
||||
static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mExpression;
|
||||
PRBool mQuerySubDirectories;
|
||||
@ -169,11 +165,4 @@ protected:
|
||||
nsCOMPtr<nsIAbDirectory> mDirectory;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewAbDirectoryQuerySimpleBooleanExpression(nsIAbBooleanExpression** aInstancePtrResult);
|
||||
|
||||
nsresult
|
||||
NS_NewIAbDirectoryQueryArguments(nsIAbDirectoryQueryArguments** aInstancePtrResult);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -144,9 +144,7 @@ nsAbLDAPAutoCompFormatter::Format(nsILDAPMessage *aMsg,
|
||||
}
|
||||
|
||||
// all done; return the item
|
||||
//
|
||||
NS_IF_ADDREF(*aItem = item);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -343,7 +341,7 @@ nsAbLDAPAutoCompFormatter::FormatException(PRInt32 aState,
|
||||
}
|
||||
}
|
||||
|
||||
// this is a remote addresbook, set the class name so the autocomplete
|
||||
// this is a remote addressbook, set the class name so the autocomplete
|
||||
// item can be styled to show this
|
||||
//
|
||||
rv = item->SetClassName("remote-err");
|
||||
@ -355,7 +353,6 @@ nsAbLDAPAutoCompFormatter::FormatException(PRInt32 aState,
|
||||
// all done; return the item
|
||||
//
|
||||
NS_IF_ADDREF(*aItem = item);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -46,5 +46,14 @@ nsAbLDAPCard::~nsAbLDAPCard()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsAbLDAPCard, nsRDFResource, nsIAbCard)
|
||||
NS_IMETHODIMP nsAbLDAPCard::EditCardToDatabase(const char *aURI)
|
||||
{
|
||||
// do nothing, you can't edit LDAP cards.
|
||||
// XXX we shouldn't be getting here, but we are because
|
||||
// the UI doesn't disable in this case. fix this later.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsAbLDAPCard, nsAbCardProperty)
|
||||
|
||||
|
@ -39,19 +39,18 @@
|
||||
#ifndef nsAbLDAPCard_h__
|
||||
#define nsAbLDAPCard_h__
|
||||
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsAbCardProperty.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
class nsAbLDAPCard : public nsRDFResource, public nsAbCardProperty
|
||||
class nsAbLDAPCard : public nsAbCardProperty
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD EditCardToDatabase(const char *aURI);
|
||||
|
||||
nsAbLDAPCard();
|
||||
virtual ~nsAbLDAPCard();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -121,7 +121,6 @@ NS_IMETHODIMP nsAbLDAPDirFactory::CreateDirectory(
|
||||
directory->SetDirName(description);
|
||||
|
||||
NS_IF_ADDREF(*_retval = new nsSingletonEnumerator(directory));
|
||||
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -180,22 +180,6 @@ NS_IMETHODIMP nsAbLDAPDirectory::HasCard(nsIAbCard* card, PRBool* hasCard)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::GetTotalCards(PRBool subDirectoryCount,
|
||||
PRUint32 *_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = Initiate ();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Enter lock
|
||||
nsAutoLock lock (mLock);
|
||||
*_retval = NS_STATIC_CAST(PRUint32 ,mCache.Count ());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* nsAbLDAPDirectoryQuery methods
|
||||
@ -209,9 +193,7 @@ nsresult nsAbLDAPDirectory::GetLDAPConnection (nsILDAPConnection** connection)
|
||||
rv = InitiateConnection ();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*connection = mConnection;
|
||||
NS_IF_ADDREF(*connection);
|
||||
|
||||
NS_IF_ADDREF(*connection = mConnection);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -222,53 +204,21 @@ nsresult nsAbLDAPDirectory::GetLDAPURL (nsILDAPURL** url)
|
||||
rv = InitiateConnection ();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*url = mURL;
|
||||
NS_IF_ADDREF(*url);
|
||||
|
||||
NS_IF_ADDREF(*url = mURL);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbLDAPDirectory::CreateCard (nsILDAPURL* uri, const char* dn, nsIAbCard** card)
|
||||
nsresult nsAbLDAPDirectory::CreateCard (nsILDAPURL* uri, const char* dn, nsIAbCard** result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString cardUri;
|
||||
rv = CreateCardURI (uri, dn, getter_Copies (cardUri));
|
||||
nsCOMPtr <nsIAbCard> card = do_CreateInstance(NS_ABLDAPCARD_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> res;
|
||||
rv = gRDFService->GetResource(cardUri, getter_AddRefs(res));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = res->QueryInterface(NS_GET_IID(nsIAbCard), NS_REINTERPRET_CAST(void**, card));
|
||||
NS_IF_ADDREF(*card);
|
||||
|
||||
return rv;
|
||||
NS_IF_ADDREF(*result = card);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbLDAPDirectory::CreateCardURI (nsILDAPURL* uri, const char* dn, char** cardUri)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString host;
|
||||
rv = uri->GetHost(getter_Copies (host));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 port;
|
||||
rv = uri->GetPort(&port);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*cardUri = PR_smprintf("moz-abldapcard://%s:%d/%s", host.get (), port, dn);
|
||||
if(!cardUri)
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* nsIAbDirectorySearch methods
|
||||
@ -290,8 +240,8 @@ NS_IMETHODIMP nsAbLDAPDirectory::StartSearch ()
|
||||
rv = StopSearch ();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbDirectoryQueryArguments> arguments;
|
||||
NS_NewIAbDirectoryQueryArguments (getter_AddRefs(arguments));
|
||||
nsCOMPtr<nsIAbDirectoryQueryArguments> arguments = do_CreateInstance(NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID,&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = arguments->SetExpression (mExpression);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -317,7 +267,14 @@ NS_IMETHODIMP nsAbLDAPDirectory::StartSearch ()
|
||||
queryListener = _queryListener;
|
||||
|
||||
// Perform the query
|
||||
rv = DoQuery (arguments, queryListener, 100, 0, &mContext);
|
||||
//
|
||||
// XXX todo, instead of 100, use the ldap_2.servers.xxx.maxHits pref
|
||||
// the problem is how to get that value here.
|
||||
//
|
||||
// I'm thinking that nsAbDirectories should know their key so that
|
||||
// they can do a lookup of server values from the key, when they need it
|
||||
// (as those values can change)
|
||||
rv = DoQuery(arguments, queryListener, 100, 0, &mContext);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Enter lock
|
||||
@ -383,10 +340,23 @@ nsresult nsAbLDAPDirectory::OnSearchFoundCard (nsIAbCard* card)
|
||||
}
|
||||
// Exit lock
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->NotifyDirectoryItemAdded(this, card);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::GetSupportsMailingLists(PRBool *aSupportsMailingsLists)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSupportsMailingsLists);
|
||||
*aSupportsMailingsLists = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::GetIsRemote(PRBool *aIsRemote)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsRemote);
|
||||
*aIsRemote = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -65,13 +65,13 @@ public:
|
||||
NS_IMETHOD GetChildNodes(nsIEnumerator* *result);
|
||||
NS_IMETHOD GetChildCards(nsIEnumerator* *result);
|
||||
NS_IMETHOD HasCard(nsIAbCard *cards, PRBool *hasCard);
|
||||
NS_IMETHOD GetTotalCards(PRBool subDirectoryCount, PRUint32 *_retval);
|
||||
NS_IMETHOD GetSupportsMailingLists(PRBool *aSupportsMailingsLists);
|
||||
NS_IMETHOD GetIsRemote(PRBool *aIsRemote);
|
||||
|
||||
// nsAbLDAPDirectoryQuery methods
|
||||
nsresult GetLDAPConnection (nsILDAPConnection** connection);
|
||||
nsresult GetLDAPURL (nsILDAPURL** url);
|
||||
nsresult CreateCard (nsILDAPURL* uri, const char* dn, nsIAbCard** card);
|
||||
nsresult CreateCardURI (nsILDAPURL* uri, const char* dn, char** cardUri);
|
||||
|
||||
// nsIAbDirectorySearch methods
|
||||
NS_DECL_NSIABDIRECTORYSEARCH
|
||||
@ -89,6 +89,7 @@ protected:
|
||||
PRBool mInitializedConnection;
|
||||
PRBool mPerformingQuery;
|
||||
PRInt32 mContext;
|
||||
PRInt32 mMaxHits;
|
||||
|
||||
nsCOMPtr<nsILDAPURL> mURL ;
|
||||
nsCOMPtr<nsILDAPConnection> mConnection;
|
||||
|
@ -19,8 +19,11 @@
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Original Author:
|
||||
* Paul Sandoz <paul.sandoz@sun.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Created by: Paul Sandoz <paul.sandoz@sun.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -45,6 +48,7 @@
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
|
||||
class nsAbQueryLDAPMessageListener : public nsILDAPMessageListener
|
||||
{
|
||||
@ -247,7 +251,14 @@ NS_IMETHODIMP nsAbQueryLDAPMessageListener::OnLDAPInit(nsresult aStatus)
|
||||
do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = ldapOperation->Init(mConnection, this);
|
||||
nsCOMPtr<nsILDAPMessageListener> proxyListener;
|
||||
rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener *, this),
|
||||
PROXY_SYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(proxyListener));
|
||||
|
||||
rv = ldapOperation->Init(mConnection, proxyListener);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Bind
|
||||
@ -267,7 +278,16 @@ nsresult nsAbQueryLDAPMessageListener::OnLDAPMessageBind (nsILDAPMessage *aMessa
|
||||
mSearchOperation = do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mSearchOperation->Init (mConnection, this);
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyMgr =
|
||||
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsILDAPMessageListener> proxyListener;
|
||||
rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsILDAPMessageListener),
|
||||
this, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs(proxyListener));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mSearchOperation->Init (mConnection, proxyListener);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString dn;
|
||||
@ -316,29 +336,9 @@ nsresult nsAbQueryLDAPMessageListener::OnLDAPMessageSearchEntry (nsILDAPMessage
|
||||
n.Assign (properties[i]);
|
||||
|
||||
nsAbDirectoryQueryPropertyValue* _propertyValue = 0;
|
||||
if (n.Equals(NS_LITERAL_CSTRING("card:URI")))
|
||||
if (n.Equals("card:nsIAbCard"))
|
||||
{
|
||||
// Meta property
|
||||
//
|
||||
|
||||
nsXPIDLString dn;
|
||||
rv = aMessage->GetDn (getter_Copies (dn));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = mDirectoryQuery->CreateCardURI (mUrl, NS_ConvertUCS2toUTF8(dn).get(), getter_Copies (uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ConvertUTF8toUCS2 v (uri.get ());
|
||||
|
||||
_propertyValue = new nsAbDirectoryQueryPropertyValue(n.get (), v.get ());
|
||||
if (_propertyValue == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else if (n.Equals(NS_LITERAL_CSTRING("card:nsIAbCard")))
|
||||
{
|
||||
// Meta property
|
||||
//
|
||||
|
||||
nsXPIDLString dn;
|
||||
rv = aMessage->GetDn (getter_Copies (dn));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -433,12 +433,10 @@ nsresult nsAbQueryLDAPMessageListener::QueryResultStatus (nsISupportsArray* prop
|
||||
resultStatus,
|
||||
(resultStatus == nsIAbDirectoryQueryResult::queryResultMatch) ? properties : 0);
|
||||
|
||||
if (_queryResult == NULL)
|
||||
if (!_queryResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*result = _queryResult;
|
||||
NS_IF_ADDREF(*result);
|
||||
|
||||
NS_IF_ADDREF(*result = _queryResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -672,13 +670,7 @@ nsresult nsAbLDAPDirectoryQuery::getLdapReturnAttributes (
|
||||
{
|
||||
n.Assign (properties[i]);
|
||||
|
||||
if (n.Equals(NS_LITERAL_CSTRING("card:URI")))
|
||||
{
|
||||
// Meta property
|
||||
//
|
||||
continue;
|
||||
}
|
||||
else if (n.Equals(NS_LITERAL_CSTRING("card:nsIAbCard")))
|
||||
if (n.Equals("card:nsIAbCard"))
|
||||
{
|
||||
// Meta property
|
||||
// require all attributes
|
||||
|
@ -61,7 +61,6 @@ public:
|
||||
virtual nsresult GetLDAPConnection (nsILDAPConnection** connection) = 0;
|
||||
virtual nsresult GetLDAPURL (nsILDAPURL** url) = 0;
|
||||
virtual nsresult CreateCard (nsILDAPURL* url, const char* dn, nsIAbCard** card) = 0;
|
||||
virtual nsresult CreateCardURI (nsILDAPURL* url, const char* dn, char** cardUri) = 0;
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -52,157 +52,24 @@
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsIAddressBook.h"
|
||||
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
nsAbMDBCard::nsAbMDBCard(void)
|
||||
: nsAbMDBRDFResource(), mListeners(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsAbMDBCard::~nsAbMDBCard(void)
|
||||
{
|
||||
if (mCardDatabase)
|
||||
{
|
||||
nsIAddrDBListener* listener = this;
|
||||
mCardDatabase->RemoveListener(listener);
|
||||
mCardDatabase = nsnull;
|
||||
}
|
||||
|
||||
if (mListeners)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i = mListeners->Count() - 1; i >= 0; --i)
|
||||
mListeners->RemoveElementAt(i);
|
||||
delete mListeners;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsAbMDBCard, nsAbMDBRDFResource, nsIAbCard, nsIAbMDBCard)
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsAbMDBCard, nsAbMDBCardProperty, nsIAbMDBCard)
|
||||
|
||||
|
||||
// nsiAddrDBListener methods
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCard::OnCardEntryChange
|
||||
(PRUint32 abCode, nsIAbCard *card, nsIAddrDBListener *instigator)
|
||||
{
|
||||
if (abCode == AB_NotifyPropertyChanged && card)
|
||||
{
|
||||
PRUint32 tableID;
|
||||
PRUint32 rowID;
|
||||
PRBool bMailList;
|
||||
|
||||
nsresult err = NS_OK;
|
||||
nsCOMPtr<nsIAbMDBCard> dbcard(do_QueryInterface(card, &err));
|
||||
if (NS_FAILED(err) || !dbcard)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
dbcard->GetDbTableID(&tableID);
|
||||
dbcard->GetDbRowID(&rowID);
|
||||
|
||||
card->GetIsMailList(&bMailList);
|
||||
if (m_dbTableID == tableID && m_dbRowID == rowID && m_bIsMailList == bMailList)
|
||||
{
|
||||
nsXPIDLString pDisplayName;
|
||||
card->GetDisplayName(getter_Copies(pDisplayName));
|
||||
if (pDisplayName)
|
||||
NotifyPropertyChanged("DisplayName", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pDisplayName));
|
||||
|
||||
nsXPIDLString pName;
|
||||
card->GetName(getter_Copies(pName));
|
||||
if (pName)
|
||||
NotifyPropertyChanged("Name", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pName));
|
||||
|
||||
nsXPIDLString pNickName;
|
||||
card->GetNickName(getter_Copies(pNickName));
|
||||
if (pNickName)
|
||||
NotifyPropertyChanged("NickName", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pNickName));
|
||||
|
||||
nsXPIDLString pPrimaryEmail;
|
||||
card->GetPrimaryEmail(getter_Copies(pPrimaryEmail));
|
||||
if (pPrimaryEmail)
|
||||
NotifyPropertyChanged("PrimaryEmail", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pPrimaryEmail));
|
||||
|
||||
nsXPIDLString pSecondEmail;
|
||||
card->GetSecondEmail(getter_Copies(pSecondEmail));
|
||||
if (pSecondEmail)
|
||||
NotifyPropertyChanged("SecondEmail", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pSecondEmail));
|
||||
|
||||
nsXPIDLString pWorkPhone;
|
||||
card->GetWorkPhone(getter_Copies(pWorkPhone));
|
||||
if (pWorkPhone)
|
||||
NotifyPropertyChanged("WorkPhone", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pWorkPhone));
|
||||
|
||||
nsXPIDLString pHomePhone;
|
||||
card->GetHomePhone(getter_Copies(pHomePhone));
|
||||
if (pHomePhone)
|
||||
NotifyPropertyChanged("HomePhone", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pHomePhone));
|
||||
|
||||
nsXPIDLString pFaxNumber;
|
||||
card->GetFaxNumber(getter_Copies(pFaxNumber));
|
||||
if (pFaxNumber)
|
||||
NotifyPropertyChanged("FaxNumber", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pFaxNumber));
|
||||
|
||||
nsXPIDLString pPagerNumber;
|
||||
card->GetPagerNumber(getter_Copies(pPagerNumber));
|
||||
if (pPagerNumber)
|
||||
NotifyPropertyChanged("PagerNumber", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pPagerNumber));
|
||||
|
||||
nsXPIDLString pCellularNumber;
|
||||
card->GetCellularNumber(getter_Copies(pCellularNumber));
|
||||
if (pCellularNumber)
|
||||
NotifyPropertyChanged("CellularNumber", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pCellularNumber));
|
||||
|
||||
nsXPIDLString pJobTitle;
|
||||
card->GetJobTitle(getter_Copies(pJobTitle));
|
||||
if (pJobTitle)
|
||||
NotifyPropertyChanged("JobTitle", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pJobTitle));
|
||||
|
||||
nsXPIDLString pDepartment;
|
||||
card->GetDepartment(getter_Copies(pDepartment));
|
||||
if (pDepartment)
|
||||
NotifyPropertyChanged("Department", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pDepartment));
|
||||
|
||||
nsXPIDLString pCompany;
|
||||
card->GetCompany(getter_Copies(pCompany));
|
||||
if (pCompany)
|
||||
NotifyPropertyChanged("Company", nsnull,
|
||||
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pCompany));
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// protected class methods
|
||||
|
||||
nsresult nsAbMDBCard::NotifyPropertyChanged(const char *property, PRUnichar* oldValue, PRUnichar* newValue)
|
||||
nsresult nsAbMDBCard::NotifyPropertyChanged(const char *property, const PRUnichar* oldValue, const PRUnichar* newValue)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
if(NS_SUCCEEDED(QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(supports))))
|
||||
{
|
||||
//Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->NotifyItemPropertyChanged(supports, property, oldValue, newValue);
|
||||
}
|
||||
@ -210,34 +77,4 @@ nsresult nsAbMDBCard::NotifyPropertyChanged(const char *property, PRUnichar* old
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbMDBCard::AddSubNode(nsAutoString name, nsIAbCard **childCard)
|
||||
{
|
||||
if(!childCard)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString uri;
|
||||
uri.Append(mURI);
|
||||
uri.Append('/');
|
||||
|
||||
char *utf8Name = ToNewUTF8String(name);
|
||||
if (!utf8Name)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
uri.Append(utf8Name);
|
||||
nsMemory::Free(utf8Name);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> res;
|
||||
rv = rdf->GetResource(uri.get(), getter_AddRefs(res));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(res, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*childCard = card;
|
||||
NS_IF_ADDREF(*childCard);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -45,18 +45,10 @@
|
||||
#define nsAbMDBCard_h__
|
||||
|
||||
#include "nsAbMDBCardProperty.h"
|
||||
#include "nsAbMDBRDFResource.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAddrDBListener.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
|
||||
/*
|
||||
* Address Book Directory
|
||||
*/
|
||||
|
||||
class nsAbMDBCard: public nsAbMDBRDFResource, public nsAbMDBCardProperty
|
||||
class nsAbMDBCard: public nsAbMDBCardProperty
|
||||
{
|
||||
public:
|
||||
|
||||
@ -65,17 +57,10 @@ public:
|
||||
nsAbMDBCard(void);
|
||||
virtual ~nsAbMDBCard(void);
|
||||
|
||||
// nsIAddrDBListener methods:
|
||||
NS_IMETHOD OnCardEntryChange(PRUint32 abCode, nsIAbCard *card, nsIAddrDBListener *instigator);
|
||||
|
||||
protected:
|
||||
|
||||
nsresult NotifyPropertyChanged(const char *property, PRUnichar* oldValue, PRUnichar* newValue);
|
||||
nsresult AddSubNode(nsAutoString name, nsIAbCard **childDir);
|
||||
|
||||
protected:
|
||||
nsresult NotifyPropertyChanged(const char *property, const PRUnichar* oldValue, const PRUnichar* newValue);
|
||||
|
||||
nsVoidArray *mListeners;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -53,51 +53,21 @@
|
||||
#include "nsIPref.h"
|
||||
#include "nsIAddressBook.h"
|
||||
|
||||
static NS_DEFINE_CID(kAddressBookDBCID, NS_ADDRDATABASE_CID);
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
static NS_DEFINE_CID(kAddrBookCID, NS_ADDRESSBOOK_CID);
|
||||
|
||||
|
||||
nsAbMDBCardProperty::nsAbMDBCardProperty(void)
|
||||
{
|
||||
m_Key = 0;
|
||||
m_key = 0;
|
||||
m_dbTableID = 0;
|
||||
m_dbRowID = 0;
|
||||
|
||||
m_pAnonymousStrAttributes = nsnull;
|
||||
m_pAnonymousStrValues = nsnull;
|
||||
m_pAnonymousIntAttributes = nsnull;
|
||||
m_pAnonymousIntValues = nsnull;
|
||||
m_pAnonymousBoolAttributes = nsnull;
|
||||
m_pAnonymousBoolValues = nsnull;
|
||||
|
||||
}
|
||||
|
||||
nsAbMDBCardProperty::~nsAbMDBCardProperty(void)
|
||||
{
|
||||
|
||||
if (mCardDatabase)
|
||||
mCardDatabase = nsnull;
|
||||
|
||||
if (m_pAnonymousStrAttributes)
|
||||
RemoveAnonymousList(m_pAnonymousStrAttributes);
|
||||
if (m_pAnonymousIntAttributes)
|
||||
RemoveAnonymousList(m_pAnonymousIntAttributes);
|
||||
if (m_pAnonymousBoolAttributes)
|
||||
RemoveAnonymousList(m_pAnonymousBoolAttributes);
|
||||
|
||||
if (m_pAnonymousStrValues)
|
||||
RemoveAnonymousList(m_pAnonymousStrValues);
|
||||
if (m_pAnonymousIntValues)
|
||||
RemoveAnonymousList(m_pAnonymousIntValues);
|
||||
if (m_pAnonymousBoolValues)
|
||||
RemoveAnonymousList(m_pAnonymousBoolValues);
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsAbMDBCardProperty, nsAbCardProperty, nsIAbMDBCard)
|
||||
|
||||
|
||||
// nsIAbMDBCard attributes
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetDbTableID(PRUint32 *aDbTableID)
|
||||
@ -126,87 +96,13 @@ NS_IMETHODIMP nsAbMDBCardProperty::SetDbRowID(PRUint32 aDbRowID)
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetKey(PRUint32 *aKey)
|
||||
{
|
||||
*aKey = m_Key;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetAnonymousStrAttrubutesList(nsVoidArray **attrlist)
|
||||
{
|
||||
if (attrlist && m_pAnonymousStrAttributes)
|
||||
{
|
||||
*attrlist = m_pAnonymousStrAttributes;
|
||||
*aKey = m_key;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetAnonymousStrValuesList(nsVoidArray **valuelist)
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::SetKey(PRUint32 key)
|
||||
{
|
||||
if (valuelist && m_pAnonymousStrValues)
|
||||
{
|
||||
*valuelist = m_pAnonymousStrValues;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetAnonymousIntAttrubutesList(nsVoidArray **attrlist)
|
||||
{
|
||||
if (attrlist && m_pAnonymousIntAttributes)
|
||||
{
|
||||
*attrlist = m_pAnonymousIntAttributes;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetAnonymousIntValuesList(nsVoidArray **valuelist)
|
||||
{
|
||||
if (valuelist && m_pAnonymousIntValues)
|
||||
{
|
||||
*valuelist = m_pAnonymousIntValues;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetAnonymousBoolAttrubutesList(nsVoidArray **attrlist)
|
||||
{
|
||||
if (attrlist && m_pAnonymousBoolAttributes)
|
||||
{
|
||||
*attrlist = m_pAnonymousBoolAttributes;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetAnonymousBoolValuesList(nsVoidArray **valuelist)
|
||||
{
|
||||
if (valuelist && m_pAnonymousBoolValues)
|
||||
{
|
||||
*valuelist = m_pAnonymousBoolValues;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// nsIAbMDBCard methods
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::SetRecordKey(PRUint32 key)
|
||||
{
|
||||
m_Key = key;
|
||||
m_key = key;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -216,103 +112,22 @@ NS_IMETHODIMP nsAbMDBCardProperty::SetAbDatabase(nsIAddrDatabase* database)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::SetAnonymousStringAttribute
|
||||
(const char *attrname, const char *value)
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::SetStringAttribute(const char *name, const PRUnichar *value)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(mCardDatabase, "no db");
|
||||
if (!mCardDatabase)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
char* pAttribute = nsCRT::strdup(attrname);
|
||||
char* pValue = nsCRT::strdup(value);
|
||||
if (pAttribute && pValue)
|
||||
{
|
||||
rv = SetAnonymousAttribute(&m_pAnonymousStrAttributes,
|
||||
&m_pAnonymousStrValues, pAttribute, pValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCRT::free(pAttribute);
|
||||
nsCRT::free(pValue);
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
return rv;
|
||||
return mCardDatabase->SetCardValue(this, name, value, PR_TRUE /* notify */);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::SetAnonymousIntAttribute
|
||||
(const char *attrname, PRUint32 value)
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetStringAttribute(const char *name, PRUnichar **value)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(mCardDatabase, "no db");
|
||||
if (!mCardDatabase)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
char* pAttribute = nsCRT::strdup(attrname);
|
||||
PRUint32* pValue = (PRUint32 *)PR_Calloc(1, sizeof(PRUint32));
|
||||
*pValue = value;
|
||||
if (pAttribute && pValue)
|
||||
{
|
||||
rv = SetAnonymousAttribute(&m_pAnonymousIntAttributes,
|
||||
&m_pAnonymousIntValues, pAttribute, pValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCRT::free(pAttribute);
|
||||
PR_FREEIF(pValue);
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::SetAnonymousBoolAttribute
|
||||
(const char *attrname, PRBool value)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
char* pAttribute = nsCRT::strdup(attrname);
|
||||
PRBool* pValue = (PRBool *)PR_Calloc(1, sizeof(PRBool));
|
||||
*pValue = value;
|
||||
if (pAttribute && pValue)
|
||||
{
|
||||
rv = SetAnonymousAttribute(&m_pAnonymousBoolAttributes,
|
||||
&m_pAnonymousBoolValues, pAttribute, pValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCRT::free(pAttribute);
|
||||
PR_FREEIF(pValue);
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* caller need to PR_smprintf_free *uri */
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetCardURI(char **uri)
|
||||
{
|
||||
char* cardURI = nsnull;
|
||||
nsFileSpec *filePath = nsnull;
|
||||
if (mCardDatabase)
|
||||
{
|
||||
mCardDatabase->GetDbPath(&filePath);
|
||||
if (filePath)
|
||||
{
|
||||
char* file = nsnull;
|
||||
file = filePath->GetLeafName();
|
||||
if (file && m_dbRowID)
|
||||
{
|
||||
if (m_bIsMailList)
|
||||
cardURI = PR_smprintf("%s%s/ListCard%ld", kMDBCardRoot, file, m_dbRowID);
|
||||
else
|
||||
cardURI = PR_smprintf("%s%s/Card%ld", kMDBCardRoot, file, m_dbRowID);
|
||||
}
|
||||
if (file)
|
||||
nsCRT::free(file);
|
||||
delete filePath;
|
||||
}
|
||||
}
|
||||
if (cardURI)
|
||||
{
|
||||
*uri = cardURI;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return mCardDatabase->GetCardValue(this, name, value);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::CopyCard(nsIAbMDBCard* srcCardDB)
|
||||
@ -410,78 +225,6 @@ NS_IMETHODIMP nsAbMDBCardProperty::CopyCard(nsIAbMDBCard* srcCardDB)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::AddAnonymousAttributesToDB()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mCardDatabase)
|
||||
mCardDatabase = nsnull;
|
||||
rv = GetCardDatabase(kPersonalAddressbookUri);
|
||||
if (NS_SUCCEEDED(rv) && mCardDatabase)
|
||||
rv = mCardDatabase->AddAnonymousAttributesFromCard(this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::EditAnonymousAttributesInDB()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mCardDatabase)
|
||||
mCardDatabase = nsnull;
|
||||
rv = GetCardDatabase(kPersonalAddressbookUri);
|
||||
if (NS_SUCCEEDED(rv) && mCardDatabase)
|
||||
rv = mCardDatabase->EditAnonymousAttributesFromCard(this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// nsIAbCard methods
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::GetPrintCardUrl(char * *aPrintCardUrl)
|
||||
{
|
||||
static const char *kAbPrintUrlFormat = "addbook:printone?email=%s&folder=%s";
|
||||
|
||||
if (!aPrintCardUrl)
|
||||
return NS_OK;
|
||||
|
||||
nsXPIDLString email;
|
||||
GetPrimaryEmail(getter_Copies(email));
|
||||
nsAutoString emailStr(email);
|
||||
|
||||
if (emailStr.Length() == 0)
|
||||
{
|
||||
*aPrintCardUrl = PR_smprintf("");
|
||||
return NS_OK;
|
||||
}
|
||||
nsXPIDLString dirName;
|
||||
if (mCardDatabase)
|
||||
mCardDatabase->GetDirectoryName(getter_Copies(dirName));
|
||||
nsAutoString dirNameStr(dirName);
|
||||
if (dirNameStr.Length() == 0)
|
||||
{
|
||||
*aPrintCardUrl = PR_smprintf("");
|
||||
return NS_OK;
|
||||
}
|
||||
dirNameStr.ReplaceSubstring(NS_LITERAL_STRING(" ").get(), NS_LITERAL_STRING("%20").get());
|
||||
|
||||
char *emailCharStr = ToNewUTF8String(emailStr);
|
||||
char *dirCharStr = ToNewUTF8String(dirNameStr);
|
||||
|
||||
*aPrintCardUrl = PR_smprintf(kAbPrintUrlFormat, emailCharStr, dirCharStr);
|
||||
|
||||
nsMemory::Free(emailCharStr);
|
||||
nsMemory::Free(dirCharStr);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::EditCardToDatabase(const char *uri)
|
||||
{
|
||||
if (!mCardDatabase && uri)
|
||||
@ -490,16 +233,13 @@ NS_IMETHODIMP nsAbMDBCardProperty::EditCardToDatabase(const char *uri)
|
||||
if (mCardDatabase)
|
||||
{
|
||||
mCardDatabase->EditCard(this, PR_TRUE);
|
||||
mCardDatabase->Commit(kLargeCommit);
|
||||
mCardDatabase->Commit(nsAddrDBCommitType::kLargeCommit);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// protected class methods
|
||||
|
||||
nsresult nsAbMDBCardProperty::GetCardDatabase(const char *uri)
|
||||
@ -507,7 +247,7 @@ nsresult nsAbMDBCardProperty::GetCardDatabase(const char *uri)
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsFileSpec* dbPath;
|
||||
@ -520,7 +260,7 @@ nsresult nsAbMDBCardProperty::GetCardDatabase(const char *uri)
|
||||
if (dbPath->Exists())
|
||||
{
|
||||
nsCOMPtr<nsIAddrDatabase> addrDBFactory =
|
||||
do_GetService(kAddressBookDBCID, &rv);
|
||||
do_GetService(NS_ADDRDATABASE_CONTRACTID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
rv = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(mCardDatabase), PR_TRUE);
|
||||
@ -532,48 +272,42 @@ nsresult nsAbMDBCardProperty::GetCardDatabase(const char *uri)
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsAbMDBCardProperty::RemoveAnonymousList(nsVoidArray* pArray)
|
||||
{
|
||||
if (pArray)
|
||||
{
|
||||
PRUint32 count = pArray->Count();
|
||||
for (int i = count - 1; i >= 0; i--)
|
||||
NS_IMETHODIMP nsAbMDBCardProperty::Equals(nsIAbCard *card, PRBool *result)
|
||||
{
|
||||
void* pPtr = pArray->ElementAt(i);
|
||||
PR_FREEIF(pPtr);
|
||||
}
|
||||
delete pArray;
|
||||
}
|
||||
return NS_OK;
|
||||
nsresult rv;
|
||||
|
||||
if (this == card) {
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// the reason we need this card at all is that multiple nsIAbCards
|
||||
// can exist for a given mdbcard
|
||||
nsCOMPtr <nsIAbMDBCard> mdbcard = do_QueryInterface(card, &rv);
|
||||
if (NS_FAILED(rv) || !mdbcard) {
|
||||
// XXX using ldap can get us here, we need to fix how the listeners work
|
||||
*result = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX todo
|
||||
// optimize this code, key might be enough
|
||||
PRUint32 dbRowID;
|
||||
rv = mdbcard->GetDbRowID(&dbRowID);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRUint32 dbTableID;
|
||||
rv = mdbcard->GetDbTableID(&dbTableID);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRUint32 key;
|
||||
rv = mdbcard->GetKey(&key);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (dbRowID == m_dbRowID && dbTableID == m_dbTableID && key == m_key)
|
||||
*result = PR_TRUE;
|
||||
else
|
||||
*result = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbMDBCardProperty::SetAnonymousAttribute
|
||||
(nsVoidArray** pAttrAray, nsVoidArray** pValueArray, void *attrname, void *value)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsVoidArray* pAttributes = *pAttrAray;
|
||||
nsVoidArray* pValues = *pValueArray;
|
||||
|
||||
if (!pAttributes && !pValues)
|
||||
{
|
||||
pAttributes = new nsVoidArray();
|
||||
pValues = new nsVoidArray();
|
||||
*pAttrAray = pAttributes;
|
||||
*pValueArray = pValues;
|
||||
}
|
||||
if (pAttributes && pValues)
|
||||
{
|
||||
if (attrname && value)
|
||||
{
|
||||
pAttributes->AppendElement(attrname);
|
||||
pValues->AppendElement(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -53,30 +53,17 @@ public:
|
||||
nsAbMDBCardProperty(void);
|
||||
virtual ~nsAbMDBCardProperty();
|
||||
|
||||
// nsIAbCard methods
|
||||
NS_IMETHODIMP GetPrintCardUrl(char * *aPrintCardUrl);
|
||||
NS_IMETHODIMP EditCardToDatabase(const char *uri);
|
||||
NS_IMETHOD EditCardToDatabase(const char *uri);
|
||||
NS_IMETHOD Equals(nsIAbCard *card, PRBool *result);
|
||||
|
||||
protected:
|
||||
nsresult GetCardDatabase(const char *uri);
|
||||
|
||||
PRUint32 m_Key;
|
||||
PRUint32 m_key;
|
||||
PRUint32 m_dbTableID;
|
||||
PRUint32 m_dbRowID;
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> mCardDatabase;
|
||||
|
||||
nsresult RemoveAnonymousList(nsVoidArray* pArray);
|
||||
nsresult SetAnonymousAttribute(nsVoidArray** pAttrAray,
|
||||
nsVoidArray** pValueArray, void *attrname, void *value);
|
||||
|
||||
nsVoidArray* m_pAnonymousStrAttributes;
|
||||
nsVoidArray* m_pAnonymousStrValues;
|
||||
nsVoidArray* m_pAnonymousIntAttributes;
|
||||
nsVoidArray* m_pAnonymousIntValues;
|
||||
nsVoidArray* m_pAnonymousBoolAttributes;
|
||||
nsVoidArray* m_pAnonymousBoolValues;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsAbMDBCardProperty_h__
|
||||
|
@ -197,9 +197,8 @@ NS_IMETHODIMP nsAbMDBDirFactory::CreateDirectory(
|
||||
nsSingletonEnumerator* cursor = new nsSingletonEnumerator(directory);
|
||||
if(!cursor)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*_retval = cursor;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
|
||||
|
||||
NS_IF_ADDREF(*_retval = cursor);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
@ -49,17 +50,13 @@
|
||||
#include "nsIAbListener.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsIAddressBook.h"
|
||||
#include "nsIAbMDBCard.h"
|
||||
|
||||
#include "mdb.h"
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
#include "prmem.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
// static NS_DEFINE_CID(kAbCardCID, NS_ABCARD_CID);
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
static NS_DEFINE_CID(kAddrBookCID, NS_ADDRESSBOOK_CID);
|
||||
|
||||
nsAbMDBDirProperty::nsAbMDBDirProperty(void)
|
||||
{
|
||||
}
|
||||
@ -152,12 +149,6 @@ NS_IMETHODIMP nsAbMDBDirProperty::CopyDBMailList(nsIAbMDBDirectory* srcListDB)
|
||||
|
||||
// nsIAbMDBDirectory NOT IMPLEMENTED methods
|
||||
|
||||
/* nsIAbCard addChildCards (in string uriName); */
|
||||
NS_IMETHODIMP nsAbMDBDirProperty::AddChildCards(const char *uriName, nsIAbCard **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIAbDirectory addDirectory (in string uriName); */
|
||||
NS_IMETHODIMP nsAbMDBDirProperty::AddDirectory(const char *uriName, nsIAbDirectory **_retval)
|
||||
{
|
||||
@ -194,3 +185,30 @@ NS_IMETHODIMP nsAbMDBDirProperty::ClearDatabase()
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBDirProperty::GetValueForCard(nsIAbCard *card, const char *name, PRUnichar **value)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIAbMDBCard> mdbcard = do_QueryInterface(card, &rv);
|
||||
if (NS_FAILED(rv) || !mdbcard) {
|
||||
// XXX this shouldn't happen
|
||||
// but it is, after ab sync
|
||||
// I think are nsAbCardProperties are getting into the nsAbView
|
||||
// and later, on paint, we are asking for them.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = mdbcard->GetStringAttribute(name, value);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBDirProperty::SetValueForCard(nsIAbCard *card, const char *name, const PRUnichar *value)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIAbMDBCard> mdbcard = do_QueryInterface(card, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mdbcard->SetStringAttribute(name, value);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return rv;
|
||||
}
|
@ -65,6 +65,9 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIABMDBDIRECTORY
|
||||
|
||||
NS_IMETHOD GetValueForCard(nsIAbCard *card, const char *name, PRUnichar **value);
|
||||
NS_IMETHOD SetValueForCard(nsIAbCard *card, const char *name, const PRUnichar *value);
|
||||
|
||||
protected:
|
||||
|
||||
PRUint32 m_dbRowID;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,6 @@
|
||||
#ifndef nsAbMDBDirectory_h__
|
||||
#define nsAbMDBDirectory_h__
|
||||
|
||||
#include "nsAbMDBRDFResource.h"
|
||||
#include "nsAbMDBDirProperty.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsISupportsArray.h"
|
||||
@ -53,22 +52,26 @@
|
||||
#include "nsIAbDirectorySearch.h"
|
||||
#include "nsAbDirSearchListener.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsIAddrDBListener.h"
|
||||
|
||||
/*
|
||||
* Address Book Directory
|
||||
*/
|
||||
|
||||
class nsAbMDBDirectory:
|
||||
public nsAbMDBRDFResource, // nsIRDFResource
|
||||
public nsRDFResource,
|
||||
public nsAbMDBDirProperty, // nsIAbDirectory, nsIAbMDBDirectory
|
||||
public nsIAbDirectorySearch,
|
||||
public nsAbDirSearchListenerContext
|
||||
public nsAbDirSearchListenerContext,
|
||||
public nsIAddrDBListener,
|
||||
public nsIAbDirectorySearch
|
||||
{
|
||||
public:
|
||||
nsAbMDBDirectory(void);
|
||||
virtual ~nsAbMDBDirectory(void);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIADDRDBLISTENER
|
||||
|
||||
// nsIRDFResource methods:
|
||||
NS_IMETHOD Init(const char* aURI);
|
||||
@ -78,7 +81,6 @@ public:
|
||||
NS_IMETHOD NotifyDirItemAdded(nsISupports *item) { return NotifyItemAdded(item);}
|
||||
NS_IMETHOD RemoveElementsFromAddressList();
|
||||
NS_IMETHOD RemoveEmailAddressAt(PRUint32 aIndex);
|
||||
NS_IMETHOD AddChildCards(const char *uriName, nsIAbCard **childCard);
|
||||
NS_IMETHOD AddDirectory(const char *uriName, nsIAbDirectory **childDir);
|
||||
NS_IMETHOD GetDirUri(char **uri);
|
||||
|
||||
@ -92,15 +94,9 @@ public:
|
||||
NS_IMETHOD CreateNewDirectory(PRUint32 prefCount, const char **prefName, const PRUnichar **prefValue);
|
||||
NS_IMETHOD CreateDirectoryByURI(const PRUnichar *dirName, const char *uri, PRBool migrating);
|
||||
NS_IMETHOD AddMailList(nsIAbDirectory *list);
|
||||
NS_IMETHOD AddCard(nsIAbCard *card, nsIAbCard **_retval);
|
||||
NS_IMETHOD DropCard(nsIAbCard *card, nsIAbCard **_retval);
|
||||
NS_IMETHOD EditMailListToDatabase(const char *uri);
|
||||
NS_IMETHOD GetTotalCards(PRBool subDirectoryCount, PRUint32 *_retval);
|
||||
|
||||
// nsIAddrDBListener methods:
|
||||
NS_IMETHOD OnCardAttribChange(PRUint32 abCode, nsIAddrDBListener *instigator);
|
||||
NS_IMETHOD OnCardEntryChange(PRUint32 abCode, nsIAbCard *card, nsIAddrDBListener *instigator);
|
||||
NS_IMETHOD OnListEntryChange(PRUint32 abCode, nsIAbDirectory *list, nsIAddrDBListener *instigator);
|
||||
NS_IMETHOD AddCard(nsIAbCard *card, nsIAbCard **addedCard);
|
||||
NS_IMETHOD DropCard(nsIAbCard *card, PRBool needToCopyCard);
|
||||
NS_IMETHOD EditMailListToDatabase(const char *uri, nsIAbCard *listCard);
|
||||
|
||||
// nsIAbDirectorySearch methods
|
||||
NS_DECL_NSIABDIRECTORYSEARCH
|
||||
@ -112,17 +108,20 @@ public:
|
||||
PRBool IsMailingList(){ return (mIsMailingList == 1); }
|
||||
|
||||
protected:
|
||||
nsresult NotifyPropertyChanged(const char *property, PRUnichar* oldValue, PRUnichar* newValue);
|
||||
nsresult NotifyPropertyChanged(nsIAbDirectory *list, const char *property, const PRUnichar* oldValue, const PRUnichar* newValue);
|
||||
nsresult NotifyItemAdded(nsISupports *item);
|
||||
nsresult NotifyItemDeleted(nsISupports *item);
|
||||
nsresult AddChildCards(nsAutoString name, nsIAbCard **childDir);
|
||||
nsresult NotifyItemChanged(nsISupports *item);
|
||||
nsresult DeleteDirectoryCards(nsIAbDirectory* directory, DIR_Server *server);
|
||||
nsresult RemoveCardFromAddressList(const nsIAbCard* card);
|
||||
nsresult RemoveCardFromAddressList(nsIAbCard* card);
|
||||
|
||||
nsresult AddMailList(const char *uriName);
|
||||
|
||||
nsVoidArray* GetDirList(){ return DIR_GetDirectories(); }
|
||||
|
||||
nsresult GetAbDatabase();
|
||||
nsCOMPtr<nsIAddrDatabase> mDatabase;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupportsArray> mSubDirectories;
|
||||
PRBool mInitialized;
|
||||
|
@ -1,129 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAbMDBRDFResource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsAddrDatabase.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDBCID, NS_ADDRDATABASE_CID);
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
|
||||
|
||||
nsAbMDBRDFResource::nsAbMDBRDFResource(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mDatabase = nsnull;
|
||||
}
|
||||
|
||||
nsAbMDBRDFResource::~nsAbMDBRDFResource(void)
|
||||
{
|
||||
if (mDatabase)
|
||||
{
|
||||
mDatabase->RemoveListener(this);
|
||||
mDatabase->Close(PR_TRUE);
|
||||
mDatabase = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsAbMDBRDFResource, nsRDFResource, nsIAddrDBListener)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP nsAbMDBRDFResource::OnCardAttribChange(PRUint32 abCode, nsIAddrDBListener *instigator)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBRDFResource::OnCardEntryChange
|
||||
(PRUint32 abCode, nsIAbCard *card, nsIAddrDBListener *instigator)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBRDFResource::OnListEntryChange
|
||||
(PRUint32 abCode, nsIAbDirectory *list, nsIAddrDBListener *instigator)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBRDFResource::OnAnnouncerGoingAway(nsIAddrDBAnnouncer *instigator)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbMDBRDFResource::GetAbDatabase()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!mDatabase && mURI)
|
||||
{
|
||||
nsFileSpec* dbPath = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->GetUserProfileDirectory(&dbPath);
|
||||
|
||||
nsCAutoString file(&(mURI[PL_strlen(kMDBDirectoryRoot)]));
|
||||
PRInt32 pos = file.Find("/");
|
||||
if (pos != -1)
|
||||
file.Truncate(pos);
|
||||
(*dbPath) += file.get();
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> addrDBFactory =
|
||||
do_GetService(kAddressBookDBCID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
rv = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);
|
||||
|
||||
if (mDatabase)
|
||||
mDatabase->AddListener(this);
|
||||
|
||||
delete dbPath;
|
||||
}
|
||||
if (!mDatabase)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/********************************************************************************************************
|
||||
|
||||
Interface for representing Address Book Directory
|
||||
|
||||
*********************************************************************************************************/
|
||||
|
||||
#ifndef nsAbMDBRDFResource_h__
|
||||
#define nsAbMDBRDFResource_h__
|
||||
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsIAbDirectory.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDirPrefs.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsIAddrDBListener.h"
|
||||
|
||||
/*
|
||||
* Address Book RDF Resources and DB listener
|
||||
*/
|
||||
|
||||
class nsAbMDBRDFResource: public nsRDFResource, public nsIAddrDBListener
|
||||
{
|
||||
public:
|
||||
nsAbMDBRDFResource(void);
|
||||
virtual ~nsAbMDBRDFResource(void);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIADDRDBLISTENER
|
||||
|
||||
protected:
|
||||
|
||||
nsresult GetAbDatabase();
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> mDatabase;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -19,8 +19,11 @@
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Original Author:
|
||||
* Cyrille Moureaux <Cyrille.Moureaux@sun.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Created by Cyrille Moureaux <Cyrille.Moureaux@sun.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -37,6 +40,10 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsAbOutlookCard.h"
|
||||
#include "nsAbWinHelper.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
|
||||
#include "prlog.h"
|
||||
|
||||
@ -241,7 +248,9 @@ static void UnicodeToWord(const PRUnichar *aUnicode, WORD& aWord)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbOutlookCard::EditCardToDatabase(const char *aUri)
|
||||
#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
|
||||
|
||||
NS_IMETHODIMP nsAbOutlookCard::EditCardToDatabase(const char *aUru)
|
||||
{
|
||||
nsresult retCode = NS_OK ;
|
||||
nsXPIDLString *properties = nsnull ;
|
||||
@ -263,8 +272,25 @@ NS_IMETHODIMP nsAbOutlookCard::EditCardToDatabase(const char *aUri)
|
||||
// name, and when all fails, on the email address.
|
||||
GetDisplayName(getter_Copies(properties [index_DisplayName])) ;
|
||||
if (*properties [index_DisplayName].get() == 0) {
|
||||
GetName(getter_Copies(properties [index_DisplayName])) ;
|
||||
if (*properties [index_DisplayName].get() == 0) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRInt32 format;
|
||||
rv = prefBranch->GetIntPref(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, &format);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = abSession->GenerateNameFromCard(this, format, getter_Copies(properties [index_DisplayName]));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (*properties[index_DisplayName].get() == 0) {
|
||||
GetPrimaryEmail(getter_Copies(properties [index_DisplayName])) ;
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ NS_IMETHODIMP nsAbOutlookDirectory::Init(const char *aUri)
|
||||
prefix.Append(unichars) ;
|
||||
SetDirName(prefix.get()) ;
|
||||
if (objectType == MAPI_DISTLIST) {
|
||||
SetListName(unichars.get()) ;
|
||||
SetDirName(unichars.get()) ;
|
||||
SetIsMailList(PR_TRUE) ;
|
||||
}
|
||||
else {
|
||||
@ -219,7 +219,7 @@ NS_IMETHODIMP nsAbOutlookDirectory::GetChildCards(nsIEnumerator **aCards)
|
||||
m_AddressList->AppendElement(mailList) ;
|
||||
NotifyItemAddition(mailList) ;
|
||||
}
|
||||
else if (m_bIsMailList) {
|
||||
else if (m_IsMailList) {
|
||||
m_AddressList->AppendElement(card) ;
|
||||
NotifyItemAddition(card) ;
|
||||
}
|
||||
@ -320,7 +320,7 @@ NS_IMETHODIMP nsAbOutlookDirectory::DeleteCards(nsISupportsArray *aCardList)
|
||||
nsVoidKey key (NS_STATIC_CAST(void *, element)) ;
|
||||
|
||||
mCardList.Remove(&key) ;
|
||||
if (m_bIsMailList) { m_AddressList->RemoveElement(element) ; }
|
||||
if (m_IsMailList) { m_AddressList->RemoveElement(element) ; }
|
||||
retCode = NotifyItemDeletion(element) ;
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
}
|
||||
@ -361,11 +361,13 @@ NS_IMETHODIMP nsAbOutlookDirectory::DeleteDirectory(nsIAbDirectory *aDirectory)
|
||||
return retCode ;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbOutlookDirectory::AddCard(nsIAbCard *aData, nsIAbCard **aCard)
|
||||
NS_IMETHODIMP nsAbOutlookDirectory::AddCard(nsIAbCard *aData, nsIAbCard **addedCard)
|
||||
{
|
||||
if (mIsQueryURI) { return NS_ERROR_NOT_IMPLEMENTED ; }
|
||||
if (!aData || !aCard) { return NS_ERROR_NULL_POINTER ; }
|
||||
*aCard = nsnull ;
|
||||
if (mIsQueryURI)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aData);
|
||||
|
||||
nsresult retCode = NS_OK ;
|
||||
PRBool hasCard = PR_FALSE ;
|
||||
|
||||
@ -373,28 +375,30 @@ NS_IMETHODIMP nsAbOutlookDirectory::AddCard(nsIAbCard *aData, nsIAbCard **aCard)
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
if (hasCard) {
|
||||
PRINTF(("Has card.\n")) ;
|
||||
NS_IF_ADDREF(*addedCard = aData);
|
||||
return NS_OK ;
|
||||
}
|
||||
retCode = CreateCard(aData, aCard) ;
|
||||
retCode = CreateCard(aData, addedCard) ;
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
nsVoidKey newKey (NS_STATIC_CAST(void *, *aCard)) ;
|
||||
nsVoidKey newKey (NS_STATIC_CAST(void *, *addedCard)) ;
|
||||
|
||||
mCardList.Put(&newKey, *aCard) ;
|
||||
if (m_bIsMailList) { m_AddressList->AppendElement(*aCard) ; }
|
||||
NotifyItemAddition(*aCard) ;
|
||||
mCardList.Put(&newKey, *addedCard) ;
|
||||
if (m_IsMailList) { m_AddressList->AppendElement(*addedCard) ; }
|
||||
NotifyItemAddition(*addedCard) ;
|
||||
return retCode ;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbOutlookDirectory::DropCard(nsIAbCard *aData, nsIAbCard **aCard)
|
||||
NS_IMETHODIMP nsAbOutlookDirectory::DropCard(nsIAbCard *aData, PRBool needToCopyCard)
|
||||
{
|
||||
return AddCard(aData, aCard) ;
|
||||
nsCOMPtr <nsIAbCard> addedCard;
|
||||
return AddCard(aData, getter_AddRefs(addedCard));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbOutlookDirectory::AddMailList(nsIAbDirectory *aMailList)
|
||||
{
|
||||
if (mIsQueryURI) { return NS_ERROR_NOT_IMPLEMENTED ; }
|
||||
if (!aMailList) { return NS_ERROR_NULL_POINTER ; }
|
||||
if (m_bIsMailList) { return NS_OK ; }
|
||||
if (m_IsMailList) { return NS_OK ; }
|
||||
nsresult retCode = NS_OK ;
|
||||
nsAbWinHelperGuard mapiAddBook (mAbWinType) ;
|
||||
nsCAutoString entryString ;
|
||||
@ -429,7 +433,7 @@ NS_IMETHODIMP nsAbOutlookDirectory::AddMailList(nsIAbDirectory *aMailList)
|
||||
if (!didCopy) {
|
||||
retCode = newList->CopyMailList(aMailList) ;
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
retCode = newList->EditMailListToDatabase(mURINoQuery.get()) ;
|
||||
retCode = newList->EditMailListToDatabase(mURINoQuery.get(), nsnull) ;
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
}
|
||||
m_AddressList->AppendElement(newList) ;
|
||||
@ -437,7 +441,7 @@ NS_IMETHODIMP nsAbOutlookDirectory::AddMailList(nsIAbDirectory *aMailList)
|
||||
return retCode ;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbOutlookDirectory::EditMailListToDatabase(const char *aUri)
|
||||
NS_IMETHODIMP nsAbOutlookDirectory::EditMailListToDatabase(const char *aUri, nsIAbCard *listCard)
|
||||
{
|
||||
if (mIsQueryURI) { return NS_ERROR_NOT_IMPLEMENTED ; }
|
||||
nsresult retCode = NS_OK ;
|
||||
@ -445,7 +449,7 @@ NS_IMETHODIMP nsAbOutlookDirectory::EditMailListToDatabase(const char *aUri)
|
||||
nsAbWinHelperGuard mapiAddBook (mAbWinType) ;
|
||||
|
||||
if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; }
|
||||
retCode = GetListName(getter_Copies(name)) ;
|
||||
retCode = GetDirName(getter_Copies(name)) ;
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
if (!mapiAddBook->SetPropertyUString(*mMapiData, PR_DISPLAY_NAME_W, name.get())) {
|
||||
return NS_ERROR_FAILURE ;
|
||||
@ -454,13 +458,6 @@ NS_IMETHODIMP nsAbOutlookDirectory::EditMailListToDatabase(const char *aUri)
|
||||
return retCode ;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbOutlookDirectory::GetTotalCards(PRBool aSubDirectoryCount, PRUint32 *aNbCards)
|
||||
{
|
||||
if (!aNbCards) { return NS_ERROR_NULL_POINTER ; }
|
||||
*aNbCards = mCardList.Count();
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
struct OutlookTableAttr
|
||||
{
|
||||
const char *mOuterName ;
|
||||
@ -509,6 +506,7 @@ struct OutlookTableAttr
|
||||
// operators do not work on unicode strings in mapi.
|
||||
static const OutlookTableAttr OutlookTableStringToProp [] =
|
||||
{
|
||||
// replace "PrimaryEmail" with kPriEmailColumn etc.
|
||||
{"FirstName", PR_GIVEN_NAME_A},
|
||||
{"LastName", PR_SURNAME_A},
|
||||
{"DisplayName", PR_DISPLAY_NAME_A},
|
||||
@ -868,22 +866,14 @@ nsresult FillPropertyValues(nsIAbCard *aCard, nsIAbDirectoryQueryArguments *aArg
|
||||
for (i = 0 ; i < properties.GetSize() ; ++ i) {
|
||||
const char* cPropName = properties[i] ;
|
||||
newValue = nsnull ;
|
||||
if (!nsCRT::strcmp(cPropName, "card:nsIAbCard")) {
|
||||
|
||||
if (!nsCRT::strcmp(cPropName, "card:nsIAbCard")) {
|
||||
nsCOMPtr<nsISupports> bogusInterface (do_QueryInterface(aCard, &retCode)) ;
|
||||
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
newValue = new nsAbDirectoryQueryPropertyValue (cPropName, bogusInterface) ;
|
||||
}
|
||||
else if (!nsCRT::strcmp(cPropName, "card:URI")) {
|
||||
nsCOMPtr<nsIRDFResource> rdfResource (do_QueryInterface(aCard, &retCode)) ;
|
||||
nsXPIDLCString uri;
|
||||
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
retCode = rdfResource->GetValue(getter_Copies(uri)) ;
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
newValue = new nsAbDirectoryQueryPropertyValue(cPropName, NS_ConvertASCIItoUCS2(uri).get()) ;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
nsXPIDLString value ;
|
||||
|
||||
retCode = aCard->GetCardValue(cPropName, getter_Copies(value)) ;
|
||||
@ -989,10 +979,12 @@ NS_IMETHODIMP nsAbOutlookDirectory::StartSearch(void)
|
||||
retCode = StopSearch() ;
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
mCardList.Reset() ;
|
||||
nsCOMPtr<nsIAbDirectoryQueryArguments> arguments ;
|
||||
|
||||
nsCOMPtr<nsIAbBooleanExpression> expression ;
|
||||
|
||||
NS_NewIAbDirectoryQueryArguments(getter_AddRefs(arguments)) ;
|
||||
nsCOMPtr<nsIAbDirectoryQueryArguments> arguments = do_CreateInstance(NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID,&retCode);
|
||||
NS_ENSURE_SUCCESS(retCode, retCode);
|
||||
|
||||
retCode = nsAbQueryStringToExpression::Convert(mQueryString.get (), getter_AddRefs(expression)) ;
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
retCode = arguments->SetExpression(expression) ;
|
||||
@ -1032,7 +1024,7 @@ nsresult nsAbOutlookDirectory::OnSearchFoundCard(nsIAbCard *aCard)
|
||||
nsresult retCode = NS_OK ;
|
||||
|
||||
mCardList.Put(&newKey, aCard) ;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);
|
||||
if (NS_SUCCEEDED(retCode)) { abSession->NotifyDirectoryItemAdded(this, aCard) ; }
|
||||
return retCode ;
|
||||
}
|
||||
@ -1166,7 +1158,7 @@ nsresult nsAbOutlookDirectory::NotifyItemDeletion(nsISupports *aItem)
|
||||
{
|
||||
nsresult retCode = NS_OK ;
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
retCode = abSession->NotifyDirectoryItemDeleted(this, aItem) ;
|
||||
return retCode ;
|
||||
@ -1176,7 +1168,7 @@ nsresult nsAbOutlookDirectory::NotifyItemAddition(nsISupports *aItem)
|
||||
{
|
||||
nsresult retCode = NS_OK ;
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &retCode);
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
retCode = abSession->NotifyDirectoryItemAdded(this, aItem) ;
|
||||
return retCode ;
|
||||
@ -1192,7 +1184,7 @@ nsresult nsAbOutlookDirectory::CommitAddressList(void)
|
||||
PRUint32 nbCards = 0 ;
|
||||
PRUint32 i = 0 ;
|
||||
|
||||
if (!m_bIsMailList) {
|
||||
if (!m_IsMailList) {
|
||||
PRINTF(("We are not in a mailing list, no commit can be done.\n")) ;
|
||||
return NS_ERROR_UNEXPECTED ;
|
||||
}
|
||||
@ -1225,7 +1217,7 @@ nsresult nsAbOutlookDirectory::UpdateAddressList(void)
|
||||
{
|
||||
nsresult retCode = S_OK ;
|
||||
|
||||
if (m_bIsMailList) {
|
||||
if (m_IsMailList) {
|
||||
retCode = GetChildCards(getter_AddRefs(m_AddressList), nsnull) ;
|
||||
}
|
||||
else {
|
||||
@ -1253,7 +1245,7 @@ nsresult nsAbOutlookDirectory::CreateCard(nsIAbCard *aData, nsIAbCard **aNewCard
|
||||
|
||||
|
||||
sourceEntry.Assign(entryString) ;
|
||||
if (m_bIsMailList) {
|
||||
if (m_IsMailList) {
|
||||
// In the case of a mailing list, we can use the address
|
||||
// as a direct template to build the new one (which is done
|
||||
// by CopyEntry).
|
||||
@ -1271,7 +1263,7 @@ nsresult nsAbOutlookDirectory::CreateCard(nsIAbCard *aData, nsIAbCard **aNewCard
|
||||
// In the case of a mailing list, we cannot directly create a new card,
|
||||
// we have to create a temporary one in a real folder (to be able to use
|
||||
// templates) and then copy it to the mailing list.
|
||||
if (m_bIsMailList) {
|
||||
if (m_IsMailList) {
|
||||
nsMapiEntry parentEntry ;
|
||||
nsMapiEntry temporaryEntry ;
|
||||
|
||||
|
@ -68,11 +68,11 @@ public:
|
||||
NS_IMETHOD HasDirectory(nsIAbDirectory *aDirectory, PRBool *aHasDirectory) ;
|
||||
NS_IMETHOD DeleteCards(nsISupportsArray *aCardList) ;
|
||||
NS_IMETHOD DeleteDirectory(nsIAbDirectory *aDirectory) ;
|
||||
NS_IMETHOD AddCard(nsIAbCard *aData, nsIAbCard **aCard) ;
|
||||
NS_IMETHOD DropCard(nsIAbCard *aData, nsIAbCard **aCard) ;
|
||||
NS_IMETHOD AddCard(nsIAbCard *aData, nsIAbCard **addedCard);
|
||||
NS_IMETHOD DropCard(nsIAbCard *aData, PRBool needToCopyCard);
|
||||
NS_IMETHOD AddMailList(nsIAbDirectory *aMailList) ;
|
||||
NS_IMETHOD EditMailListToDatabase(const char *aUri) ;
|
||||
NS_IMETHOD GetTotalCards(PRBool aSubDirectoryCount, PRUint32 *aNbCards) ;
|
||||
NS_IMETHOD EditMailListToDatabase(const char *aUri, nsIAbCard *listCard) ;
|
||||
|
||||
// nsAbDirectoryRDFResource method
|
||||
NS_IMETHOD Init(const char *aUri) ;
|
||||
// nsIAbDirectoryQuery methods
|
||||
@ -113,8 +113,6 @@ protected:
|
||||
PRInt32 mSearchContext ;
|
||||
// Windows AB type
|
||||
PRUint32 mAbWinType ;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // nsAbOutlookDirectory_h___
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsITextToSubURI.h"
|
||||
#include "nsAbBooleanExpression.h"
|
||||
|
||||
#include "nsAbBaseCID.h"
|
||||
|
||||
nsresult nsAbQueryStringToExpression::Convert (
|
||||
const char* queryString,
|
||||
@ -69,9 +69,7 @@ nsresult nsAbQueryStringToExpression::Convert (
|
||||
nsCOMPtr<nsIAbBooleanExpression> e(do_QueryInterface(s, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*expression = e;
|
||||
NS_IF_ADDREF(*expression);
|
||||
|
||||
NS_IF_ADDREF(*expression = e);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -119,8 +117,7 @@ nsresult nsAbQueryStringToExpression::ParseExpression (
|
||||
rv = ParseExpressions (index, e);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*expression = e;
|
||||
NS_IF_ADDREF(*expression);
|
||||
NS_IF_ADDREF(*expression = e);
|
||||
}
|
||||
// Case" "(*)"
|
||||
else if (*indexBracket == ')')
|
||||
@ -132,8 +129,7 @@ nsresult nsAbQueryStringToExpression::ParseExpression (
|
||||
getter_AddRefs(conditionString));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*expression = conditionString;
|
||||
NS_IF_ADDREF(*expression);
|
||||
NS_IF_ADDREF(*expression = conditionString);
|
||||
}
|
||||
|
||||
if (**index != ')')
|
||||
@ -210,9 +206,7 @@ nsresult nsAbQueryStringToExpression::ParseCondition (
|
||||
getter_AddRefs (c));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*conditionString = c;
|
||||
NS_IF_ADDREF(*conditionString);
|
||||
|
||||
NS_IF_ADDREF(*conditionString = c);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -271,11 +265,12 @@ nsresult nsAbQueryStringToExpression::CreateBooleanExpression(
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = NS_NewIAbBooleanExpression(expression);
|
||||
nsCOMPtr <nsIAbBooleanExpression> expr = do_CreateInstance(NS_BOOLEANEXPRESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = (*expression)->SetOperation (op);
|
||||
|
||||
NS_IF_ADDREF(*expression = expr);
|
||||
|
||||
rv = expr->SetOperation (op);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -315,8 +310,7 @@ nsresult nsAbQueryStringToExpression::CreateBooleanConditionString (
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIAbBooleanConditionString> cs;
|
||||
rv = NS_NewIAbBooleanConditionString (getter_AddRefs(cs));
|
||||
nsCOMPtr<nsIAbBooleanConditionString> cs = do_CreateInstance(NS_BOOLEANCONDITIONSTRING_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = cs->SetCondition (c);
|
||||
@ -354,9 +348,7 @@ nsresult nsAbQueryStringToExpression::CreateBooleanConditionString (
|
||||
}
|
||||
|
||||
|
||||
*conditionString = cs;
|
||||
NS_IF_ADDREF(*conditionString);
|
||||
|
||||
NS_IF_ADDREF(*conditionString = cs);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -70,38 +70,21 @@ typedef struct _nsAbRDFNotification {
|
||||
} nsAbRDFNotification;
|
||||
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Utilities
|
||||
|
||||
|
||||
nsresult nsAbRDFDataSource::createNode(nsString& str, nsIRDFNode **node)
|
||||
nsresult nsAbRDFDataSource::createNode(const PRUnichar *str, nsIRDFNode **node)
|
||||
{
|
||||
*node = nsnull;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
|
||||
nsCOMPtr<nsIRDFService> rdf(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv); // always check this before proceeding
|
||||
nsCOMPtr<nsIRDFLiteral> value;
|
||||
rv = rdf->GetLiteral(str.get(), getter_AddRefs(value));
|
||||
rv = rdf->GetLiteral(str, getter_AddRefs(value));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
*node = value;
|
||||
NS_IF_ADDREF(*node);
|
||||
NS_IF_ADDREF(*node = value);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbRDFDataSource::createNode(PRUint32 value, nsIRDFNode **node)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString str;
|
||||
str.AppendInt((PRInt32)value);
|
||||
rv = createNode(str, node);
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool nsAbRDFDataSource::changeEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsAbRDFNotification* note = (nsAbRDFNotification *)aData;
|
||||
@ -301,8 +284,7 @@ nsresult nsAbRDFDataSource::NotifyPropertyChanged(nsIRDFResource *resource,
|
||||
const PRUnichar *newValue)
|
||||
{
|
||||
nsCOMPtr<nsIRDFNode> newValueNode;
|
||||
nsString newValueStr(newValue);
|
||||
createNode(newValueStr, getter_AddRefs(newValueNode));
|
||||
createNode(newValue, getter_AddRefs(newValueNode));
|
||||
NotifyObservers(resource, propertyResource, newValueNode, PR_FALSE, PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -325,7 +307,7 @@ nsAbRDFDataSource::~nsAbRDFDataSource (void)
|
||||
if (mRDFService)
|
||||
{
|
||||
mRDFService->UnregisterDataSource(this);
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||
nsServiceManager::ReleaseService("@mozilla.org/rdf/rdf-service;1", mRDFService);
|
||||
mRDFService = nsnull;
|
||||
}
|
||||
|
||||
@ -336,7 +318,7 @@ nsAbRDFDataSource::~nsAbRDFDataSource (void)
|
||||
nsresult nsAbRDFDataSource::Init()
|
||||
{
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsresult rv = nsServiceManager::GetService("@mozilla.org/rdf/rdf-service;1",
|
||||
NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**) &mRDFService);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -61,8 +61,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
nsresult createNode(nsString& str, nsIRDFNode **node);
|
||||
nsresult createNode(PRUint32 value, nsIRDFNode **node);
|
||||
nsresult createNode(const PRUnichar *str, nsIRDFNode **node);
|
||||
|
||||
nsresult NotifyPropertyChanged(
|
||||
nsIRDFResource *resource,
|
||||
|
@ -106,7 +106,7 @@ nsresult nsAbRDFResource::GetAbDatabase()
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->GetUserProfileDirectory(&dbPath);
|
||||
|
||||
nsAutoString file; file.AssignWithConversion(&(mURI[PL_strlen(kMDBDirectoryRoot)]));
|
||||
NS_ConvertUTF8toUCS2 file(&(mURI[strlen(kMDBDirectoryRoot)]));
|
||||
PRInt32 pos = file.Find("/");
|
||||
if (pos != -1)
|
||||
file.Truncate(pos);
|
||||
|
@ -336,6 +336,10 @@ NS_IMETHODIMP nsAbView::GetRowProperties(PRInt32 index, nsISupportsArray *proper
|
||||
|
||||
NS_IMETHODIMP nsAbView::GetCellProperties(PRInt32 row, const PRUnichar *colID, nsISupportsArray *properties)
|
||||
{
|
||||
// XXX todo remove once #116341 is fixed
|
||||
if (!colID[0])
|
||||
return NS_OK;
|
||||
|
||||
if (mCards.Count() <= row)
|
||||
return NS_OK;
|
||||
|
||||
@ -448,6 +452,10 @@ nsresult nsAbView::GetCardValue(nsIAbCard *card, const PRUnichar *colID, PRUnich
|
||||
|
||||
NS_IMETHODIMP nsAbView::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnichar **_retval)
|
||||
{
|
||||
// XXX todo remove once #116341 is fixed
|
||||
if (!colID[0])
|
||||
return NS_OK;
|
||||
|
||||
nsIAbCard *card = ((AbCard *)(mCards.ElementAt(row)))->card;
|
||||
return GetCardValue(card, colID, _retval);
|
||||
}
|
||||
@ -1034,7 +1042,7 @@ nsresult nsAbView::ReselectCards(nsISupportsArray *cards, nsIAbCard *indexCard)
|
||||
PRUint32 count;
|
||||
PRUint32 i;
|
||||
|
||||
if (!mOutlinerSelection)
|
||||
if (!mOutlinerSelection || !cards)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = mOutlinerSelection->ClearSelection();
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
@ -60,14 +61,10 @@
|
||||
#include "nsRDFCID.h"
|
||||
#include "prmem.h"
|
||||
|
||||
extern const char *kWorkAddressBook;
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
||||
static NS_DEFINE_CID(kCAddbookUrlCID, NS_ADDBOOKURL_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDBCID, NS_ADDRDATABASE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
extern const char *kWorkAddressBook;
|
||||
|
||||
nsAddbookProtocolHandler::nsAddbookProtocolHandler()
|
||||
{
|
||||
@ -83,18 +80,6 @@ nsAddbookProtocolHandler::~nsAddbookProtocolHandler()
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAddbookProtocolHandler, nsIProtocolHandler);
|
||||
|
||||
NS_METHOD
|
||||
nsAddbookProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsAddbookProtocolHandler* ph = new nsAddbookProtocolHandler();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return ph->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddbookProtocolHandler::GetScheme(char * *aScheme)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -118,11 +103,9 @@ NS_IMETHODIMP nsAddbookProtocolHandler::GetProtocolFlags(PRUint32 *aUritype)
|
||||
|
||||
NS_IMETHODIMP nsAddbookProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
|
||||
{
|
||||
// get a new smtp url
|
||||
// get a new addrbook url
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr <nsIURI> addbookUrl;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCAddbookUrlCID, NULL, NS_GET_IID(nsIURI), getter_AddRefs(addbookUrl));
|
||||
nsCOMPtr <nsIURI> addbookUrl = do_CreateInstance(NS_ADDBOOKURL_CONTRACTID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
@ -239,7 +222,7 @@ nsAddbookProtocolHandler::OpenAB(char *aAbName, nsIAddrDatabase **aDatabase)
|
||||
nsFileSpec* dbPath = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->GetUserProfileDirectory(&dbPath);
|
||||
|
||||
@ -251,7 +234,7 @@ nsAddbookProtocolHandler::OpenAB(char *aAbName, nsIAddrDatabase **aDatabase)
|
||||
(*dbPath) += aAbName;
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> addrDBFactory =
|
||||
do_GetService(kAddressBookDBCID, &rv);
|
||||
do_GetService(NS_ADDRDATABASE_CONTRACTID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
rv = addrDBFactory->Open(dbPath, PR_TRUE, aDatabase, PR_TRUE);
|
||||
@ -299,29 +282,7 @@ nsAddbookProtocolHandler::FindPossibleAbName(nsIAbCard *aCard,
|
||||
nsCOMPtr<nsIAbMDBCard> dbaCard(do_QueryInterface(aCard, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (NS_SUCCEEDED(dbaCard->GetAnonymousStrAttrubutesList(&attrlist)) && attrlist)
|
||||
{
|
||||
if (NS_SUCCEEDED(dbaCard->GetAnonymousStrValuesList(&valuelist)) && valuelist)
|
||||
{
|
||||
char *attr = nsnull;
|
||||
|
||||
for (PRInt32 i = 0; i<attrlist->Count(); i++)
|
||||
{
|
||||
attr = (char *)attrlist->ElementAt(i);
|
||||
|
||||
if ((attr) && (!nsCRT::strcasecmp(kWorkAddressBook, attr)))
|
||||
{
|
||||
char *val = (char *)valuelist->ElementAt(i);
|
||||
if ( (val) && (*val) )
|
||||
{
|
||||
*retName = ToNewUnicode(nsDependentCString(val));
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(0, "fix me, FindPossibleAbName");
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -348,7 +309,7 @@ nsAddbookProtocolHandler::GeneratePrintOutput(nsIAddbookUrl *addbookUrl,
|
||||
|
||||
rv = NS_OK;
|
||||
// Get the RDF service...
|
||||
nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv));
|
||||
nsCOMPtr<nsIRDFService> rdfService(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
goto EarlyExit;
|
||||
|
||||
@ -383,7 +344,7 @@ nsAddbookProtocolHandler::GeneratePrintOutput(nsIAddbookUrl *addbookUrl,
|
||||
if (!charAb)
|
||||
goto EarlyExit;
|
||||
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));
|
||||
nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv) || !pPref)
|
||||
goto EarlyExit;
|
||||
|
||||
@ -436,6 +397,8 @@ EarlyExit:
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAddbookProtocolHandler::BuildSingleHTML(nsIAddrDatabase *aDatabase, nsIAbDirectory *directory,
|
||||
char *charEmail, nsString &workBuffer)
|
||||
@ -446,7 +409,7 @@ nsAddbookProtocolHandler::BuildSingleHTML(nsIAddrDatabase *aDatabase, nsIAbDirec
|
||||
if (NS_FAILED(InitPrintColumns()))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = aDatabase->GetCardForEmailAddress(directory, charEmail, getter_AddRefs(workCard));
|
||||
nsresult rv = aDatabase->GetCardFromAttribute(directory, kPriEmailColumn, charEmail, PR_TRUE /* caseInsensitive */, getter_AddRefs(workCard));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!workCard)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -456,7 +419,21 @@ nsAddbookProtocolHandler::BuildSingleHTML(nsIAddrDatabase *aDatabase, nsIAbDirec
|
||||
workBuffer.Append(NS_LITERAL_STRING("<CENTER>"));
|
||||
workBuffer.Append(NS_LITERAL_STRING("<TABLE BORDER>"));
|
||||
|
||||
if (NS_SUCCEEDED(workCard->GetName(&aName)) && (aName))
|
||||
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRInt32 format;
|
||||
rv = prefBranch->GetIntPref(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, &format);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (NS_SUCCEEDED(abSession->GenerateNameFromCard(workCard, format, &aName)) && (aName))
|
||||
{
|
||||
workBuffer.Append(NS_LITERAL_STRING("<caption><b>"));
|
||||
workBuffer.Append(aName);
|
||||
|
@ -61,8 +61,6 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// we suppport the nsIProtocolHandler interface
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -45,22 +45,15 @@
|
||||
|
||||
const char *kWorkAddressBook = "AddbookWorkAddressBook";
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
static NS_DEFINE_CID(kAbCardProperty, NS_ABCARDPROPERTY_CID);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// addbook url definition
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
nsAddbookUrl::nsAddbookUrl()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
|
||||
NS_GET_IID(nsIURI),
|
||||
(void **) getter_AddRefs(m_baseURL));
|
||||
nsComponentManager::CreateInstance(kAbCardProperty, nsnull, NS_GET_IID(nsAbCardProperty),
|
||||
(void **) getter_AddRefs(mAbCardProperty));
|
||||
|
||||
m_baseURL = do_CreateInstance(NS_SIMPLEURI_CONTRACTID);
|
||||
mAbCardProperty = do_CreateInstance(NS_ABCARDPROPERTY_CONTRACTID);
|
||||
|
||||
mOperationType = nsIAddbookUrlOperation::InvalidUrl;
|
||||
}
|
||||
|
@ -61,25 +61,32 @@ nsAddrBookSession::~nsAddrBookSession()
|
||||
|
||||
// nsIAddrBookSession
|
||||
|
||||
NS_IMETHODIMP nsAddrBookSession::AddAddressBookListener(nsIAbListener * listener)
|
||||
NS_IMETHODIMP nsAddrBookSession::AddAddressBookListener(nsIAbListener *listener, PRUint32 notifyFlags)
|
||||
{
|
||||
if (!mListeners)
|
||||
NS_NewISupportsArray(getter_AddRefs(mListeners));
|
||||
|
||||
NS_ENSURE_TRUE(mListeners, NS_ERROR_NULL_POINTER);
|
||||
mListeners->AppendElement(listener);
|
||||
mListenerNotifyFlags.Add(notifyFlags);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrBookSession::RemoveAddressBookListener(nsIAbListener * listener)
|
||||
{
|
||||
NS_ENSURE_TRUE(mListeners, NS_ERROR_NULL_POINTER);
|
||||
|
||||
PRInt32 index;
|
||||
nsresult rv = mListeners->GetIndexOf(listener, &index);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
mListenerNotifyFlags.RemoveAt(index);
|
||||
|
||||
mListeners->RemoveElement(listener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrBookSession::NotifyItemPropertyChanged
|
||||
(nsISupports *item, const char *property, const PRUnichar* oldValue, const PRUnichar* newValue)
|
||||
NS_IMETHODIMP nsAddrBookSession::NotifyItemPropertyChanged(nsISupports *item, const char *property, const PRUnichar* oldValue, const PRUnichar* newValue)
|
||||
{
|
||||
NS_ENSURE_TRUE(mListeners, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -89,14 +96,14 @@ NS_IMETHODIMP nsAddrBookSession::NotifyItemPropertyChanged
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIAbListener> listener = getter_AddRefs((nsIAbListener*)mListeners->ElementAt(i));
|
||||
NS_ASSERTION(listener, "listener is null");
|
||||
if (listener)
|
||||
listener->OnItemPropertyChanged(item, property, oldValue, newValue);
|
||||
if (mListenerNotifyFlags[i] & nsIAbListener::changed) {
|
||||
nsCOMPtr<nsIAbListener> listener = getter_AddRefs((nsIAbListener*)mListeners->ElementAt(i));
|
||||
NS_ASSERTION(listener, "listener is null");
|
||||
if (listener)
|
||||
listener->OnItemPropertyChanged(item, property, oldValue, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryItemAdded(nsIAbDirectory *directory, nsISupports *item)
|
||||
@ -109,10 +116,12 @@ NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryItemAdded(nsIAbDirectory *direct
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIAbListener> listener = getter_AddRefs((nsIAbListener*)mListeners->ElementAt(i));
|
||||
NS_ASSERTION(listener, "listener is null");
|
||||
if (listener)
|
||||
listener->OnItemAdded(directory, item);
|
||||
if (mListenerNotifyFlags[i] & nsIAbListener::added) {
|
||||
nsCOMPtr<nsIAbListener> listener = getter_AddRefs((nsIAbListener*)mListeners->ElementAt(i));
|
||||
NS_ASSERTION(listener, "listener is null");
|
||||
if (listener)
|
||||
listener->OnItemAdded(directory, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
@ -129,16 +138,39 @@ NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryItemDeleted(nsIAbDirectory *dire
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIAbListener> listener = getter_AddRefs((nsIAbListener*)mListeners->ElementAt(i));
|
||||
NS_ASSERTION(listener, "listener is null");
|
||||
if (listener)
|
||||
listener->OnItemRemoved(directory, item);
|
||||
if (mListenerNotifyFlags[i] & nsIAbListener::directoryItemRemoved) {
|
||||
nsCOMPtr<nsIAbListener> listener = getter_AddRefs((nsIAbListener*)mListeners->ElementAt(i));
|
||||
NS_ASSERTION(listener, "listener is null");
|
||||
if (listener)
|
||||
listener->OnItemRemoved(directory, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryDeleted(nsIAbDirectory *directory, nsISupports *item)
|
||||
{
|
||||
if (mListeners)
|
||||
{
|
||||
PRUint32 count = 0;
|
||||
PRUint32 i;
|
||||
nsresult rv = mListeners->Count(&count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
if (mListenerNotifyFlags[i] & nsIAbListener::directoryRemoved) {
|
||||
nsCOMPtr<nsIAbListener> listener = getter_AddRefs(NS_STATIC_CAST(nsIAbListener *,mListeners->ElementAt(i)));
|
||||
NS_ASSERTION(listener, "listener is null");
|
||||
if (listener)
|
||||
listener->OnItemRemoved(directory, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAddrBookSession::GetUserProfileDirectory(nsFileSpec * *userDir)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(userDir);
|
||||
@ -159,16 +191,64 @@ NS_IMETHODIMP nsAddrBookSession::GetUserProfileDirectory(nsFileSpec * *userDir)
|
||||
return rv;
|
||||
}
|
||||
|
||||
// used to live in the msg view navigation service
|
||||
NS_IMETHODIMP nsAddrBookSession::EnsureDocumentIsLoaded(nsIDOMXULDocument *xulDocument)
|
||||
#define kDisplayName 0
|
||||
#define kLastFirst 1
|
||||
#define kFirstLast 2
|
||||
|
||||
NS_IMETHODIMP nsAddrBookSession::GenerateNameFromCard(nsIAbCard *card, PRInt32 generateFormat, PRUnichar **aName)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (generateFormat == kDisplayName) {
|
||||
rv = card->GetDisplayName(aName);
|
||||
}
|
||||
else {
|
||||
nsXPIDLString firstName;
|
||||
nsXPIDLString lastName;
|
||||
|
||||
rv = card->GetFirstName(getter_Copies(firstName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(xulDocument, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = card->GetLastName(getter_Copies(lastName));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (!document) return NS_ERROR_FAILURE;
|
||||
rv = document->FlushPendingNotifications();
|
||||
if (!lastName.IsEmpty() && !firstName.IsEmpty()) {
|
||||
if (!mBundle) {
|
||||
nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = stringBundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", getter_AddRefs(mBundle));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
nsXPIDLString generatedName;
|
||||
|
||||
if (generateFormat == kLastFirst) {
|
||||
const PRUnichar *stringParams[2] = {lastName.get(), firstName.get()};
|
||||
|
||||
rv = mBundle->FormatStringFromName(NS_LITERAL_STRING("lastFirstFormat").get(), stringParams, 2,
|
||||
getter_Copies(generatedName));
|
||||
}
|
||||
else {
|
||||
const PRUnichar *stringParams[2] = {firstName.get(), lastName.get()};
|
||||
|
||||
rv = mBundle->FormatStringFromName(NS_LITERAL_STRING("firstLastFormat").get(), stringParams, 2,
|
||||
getter_Copies(generatedName));
|
||||
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
*aName = ToNewUnicode(generatedName);
|
||||
}
|
||||
else {
|
||||
if (lastName.Length())
|
||||
*aName = ToNewUnicode(lastName);
|
||||
else if (firstName.Length())
|
||||
*aName = ToNewUnicode(firstName);
|
||||
else
|
||||
*aName = ToNewUnicode(NS_LITERAL_STRING(""));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -41,6 +41,8 @@
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsUInt32Array.h"
|
||||
|
||||
class nsAddrBookSession : public nsIAddrBookSession
|
||||
{
|
||||
@ -52,9 +54,9 @@ public:
|
||||
NS_DECL_NSIADDRBOOKSESSION
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsISupportsArray> mListeners;
|
||||
|
||||
nsCOMPtr <nsISupportsArray> mListeners;
|
||||
nsUInt32Array mListenerNotifyFlags;
|
||||
nsCOMPtr<nsIStringBundle> mBundle;
|
||||
};
|
||||
|
||||
#endif /* nsAddrBookSession_h__ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -46,7 +47,6 @@
|
||||
#include "nsIAddrDBListener.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICollation.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -66,13 +66,6 @@ typedef enum
|
||||
|
||||
} AB_NOTIFY_CODE;
|
||||
|
||||
enum nsAddrDBCommitType {
|
||||
kSmallCommit,
|
||||
kLargeCommit,
|
||||
kSessionCommit,
|
||||
kCompressCommit
|
||||
};
|
||||
|
||||
class nsAddrDatabase : public nsIAddrDatabase
|
||||
{
|
||||
public:
|
||||
@ -87,14 +80,12 @@ public:
|
||||
NS_IMETHOD Close(PRBool forceCommit);
|
||||
NS_IMETHOD OpenMDB(nsFileSpec *dbName, PRBool create);
|
||||
NS_IMETHOD CloseMDB(PRBool commit);
|
||||
NS_IMETHOD OpenAnonymousDB(nsIAddrDatabase **pCardDB);
|
||||
NS_IMETHOD CloseAnonymousDB(PRBool forceCommit);
|
||||
NS_IMETHOD Commit(PRUint32 commitType);
|
||||
NS_IMETHOD ForceClosed();
|
||||
|
||||
NS_IMETHOD CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool notify);
|
||||
NS_IMETHOD CreateNewCardAndAddToDBWithKey(nsIAbCard *newCard, PRBool notify, PRUint32 *key);
|
||||
NS_IMETHOD CreateNewListCardAndAddToDB(PRUint32 listRowID, nsIAbCard *newCard, PRBool notify);
|
||||
NS_IMETHOD CreateNewListCardAndAddToDB(nsIAbDirectory *list, PRUint32 listRowID, nsIAbCard *newCard, PRBool notify);
|
||||
NS_IMETHOD CreateMailListAndAddToDB(nsIAbDirectory *newList, PRBool notify);
|
||||
NS_IMETHOD EnumerateCards(nsIAbDirectory *directory, nsIEnumerator **result);
|
||||
NS_IMETHOD GetMailingListsFromDB(nsIAbDirectory *parentDir);
|
||||
@ -103,26 +94,10 @@ public:
|
||||
NS_IMETHOD EditCard(nsIAbCard *card, PRBool notify);
|
||||
NS_IMETHOD ContainsCard(nsIAbCard *card, PRBool *hasCard);
|
||||
NS_IMETHOD DeleteMailList(nsIAbDirectory *mailList, PRBool notify);
|
||||
NS_IMETHOD EditMailList(nsIAbDirectory *mailList, PRBool notify);
|
||||
NS_IMETHOD EditMailList(nsIAbDirectory *mailList, nsIAbCard *listCard, PRBool notify);
|
||||
NS_IMETHOD ContainsMailList(nsIAbDirectory *mailList, PRBool *hasCard);
|
||||
NS_IMETHOD DeleteCardFromMailList(nsIAbDirectory *mailList, nsIAbCard *card, PRBool beNotify);
|
||||
|
||||
NS_IMETHOD GetCardForEmailAddress(nsIAbDirectory *directory, const char *emailAddress, nsIAbCard **card);
|
||||
|
||||
NS_IMETHOD SetAnonymousStringAttribute(const char *attrname, const char *value);
|
||||
NS_IMETHOD GetAnonymousStringAttribute(const char *attrname, char** value);
|
||||
NS_IMETHOD SetAnonymousIntAttribute(const char *attrname, PRUint32 value);
|
||||
NS_IMETHOD GetAnonymousIntAttribute(const char *attrname, PRUint32* value);
|
||||
NS_IMETHOD SetAnonymousBoolAttribute(const char *attrname, PRBool value);
|
||||
NS_IMETHOD GetAnonymousBoolAttribute(const char *attrname, PRBool* value);
|
||||
NS_IMETHOD AddAnonymousAttributesToDB();
|
||||
NS_IMETHOD RemoveAnonymousAttributesFromDB();
|
||||
NS_IMETHOD EditAnonymousAttributesInDB();
|
||||
|
||||
NS_IMETHOD AddAnonymousAttributesFromCard(nsIAbCard *card);
|
||||
NS_IMETHOD RemoveAnonymousAttributesFromCard(nsIAbCard *card);
|
||||
NS_IMETHOD EditAnonymousAttributesFromCard(nsIAbCard *card);
|
||||
|
||||
NS_IMETHOD DeleteCardFromMailList(nsIAbDirectory *mailList, nsIAbCard *card, PRBool aNotify);
|
||||
NS_IMETHOD GetCardFromAttribute(nsIAbDirectory *directory, const char *aName, const char *aValue, PRBool aCaseInsensitive, nsIAbCard **card);
|
||||
NS_IMETHOD GetNewRow(nsIMdbRow * *newRow);
|
||||
NS_IMETHOD GetNewListRow(nsIMdbRow * *newRow);
|
||||
NS_IMETHOD AddCardRowToDB(nsIMdbRow *newRow);
|
||||
@ -248,7 +223,6 @@ public:
|
||||
|
||||
|
||||
NS_IMETHOD AddListDirNode(nsIMdbRow * listRow);
|
||||
NS_IMETHOD CreateCollationKey(const PRUnichar *sourceStr, nsString& resultStr);
|
||||
NS_IMETHOD GetDirectoryName(PRUnichar **name);
|
||||
|
||||
NS_IMETHOD FindMailListbyUnicodeName(const PRUnichar *listName, PRBool *exist);
|
||||
@ -256,7 +230,9 @@ public:
|
||||
NS_IMETHOD GetCardCount(PRUint32 *count);
|
||||
NS_IMETHOD RemoveExtraCardsInCab(PRUint32 cardTotal, PRUint32 nCabMax);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
NS_IMETHOD SetCardValue(nsIAbCard *card, const char *name, const PRUnichar *value, PRBool notify);
|
||||
NS_IMETHOD GetCardValue(nsIAbCard *card, const char *name, PRUnichar **value);
|
||||
|
||||
// nsAddrDatabase methods:
|
||||
|
||||
nsAddrDatabase();
|
||||
@ -268,14 +244,12 @@ public:
|
||||
PRUint32 GetCurVersion();
|
||||
nsIMdbTableRowCursor *GetTableRowCursor();
|
||||
nsIMdbTable *GetPabTable() {return m_mdbPabTable;}
|
||||
nsIMdbTable *GetAnonymousTable() {return m_mdbAnonymousTable;}
|
||||
|
||||
static nsAddrDatabase* FindInCache(nsFileSpec *dbName);
|
||||
|
||||
static void CleanupCache();
|
||||
|
||||
nsresult CreateABCard(nsIMdbRow* cardRow, nsIAbCard **result);
|
||||
nsresult CreateABCardInList(nsIMdbRow* cardRow, nsIAbCard **result, mdb_id listRowID);
|
||||
nsresult CreateABCard(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result);
|
||||
nsresult CreateABListCard(nsIMdbRow* listRow, nsIAbCard **result);
|
||||
nsresult CreateABList(nsIMdbRow* listRow, nsIAbDirectory **result);
|
||||
|
||||
@ -316,29 +290,19 @@ protected:
|
||||
nsresult GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow);
|
||||
nsresult GetListCardFromDB(nsIAbCard *listCard, nsIMdbRow* listRow);
|
||||
nsresult GetListFromDB(nsIAbDirectory *newCard, nsIMdbRow* listRow);
|
||||
nsresult GetAnonymousAttributesFromDB();
|
||||
nsresult AddRecordKeyColumnToRow(nsIMdbRow *pRow);
|
||||
nsresult AddAttributeColumnsToRow(nsIAbCard *card, nsIMdbRow *cardRow);
|
||||
nsresult AddListCardColumnsToRow(nsIAbCard *pCard, nsIMdbRow *pListRow, PRUint32 pos, nsIAbCard** pNewCard);
|
||||
nsresult AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIMdbRow *listRow);
|
||||
nsresult RemoveAnonymousList(nsVoidArray* pArray);
|
||||
nsresult SetAnonymousAttribute(nsVoidArray** pAttrAray,
|
||||
nsVoidArray** pValueArray, void *attrname, void *value);
|
||||
nsresult DoAnonymousAttributesTransaction(AB_NOTIFY_CODE code);
|
||||
nsresult DoStringAnonymousTransaction(nsVoidArray* pAttributes, nsVoidArray* pValues, AB_NOTIFY_CODE code);
|
||||
nsresult DoIntAnonymousTransaction(nsVoidArray* pAttributes, nsVoidArray* pValues, AB_NOTIFY_CODE code);
|
||||
nsresult DoBoolAnonymousTransaction(nsVoidArray* pAttributes, nsVoidArray* pValues, AB_NOTIFY_CODE code);
|
||||
void GetAnonymousAttributesFromCard(nsIAbCard* card);
|
||||
nsresult FindAttributeRow(nsIMdbTable* pTable, mdb_token columnToken, nsIMdbRow** row);
|
||||
nsresult GetRowForEmailAddress(const char *emailAddress, nsIMdbRow **cardRow);
|
||||
nsresult CreateCard(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result);
|
||||
nsresult SetListAddressTotal(nsIMdbRow* listRow, PRUint32 total);
|
||||
nsresult DeleteCardFromListRow(nsIMdbRow* pListRow, mdb_id cardRowID);
|
||||
void DeleteCardFromAllMailLists(mdb_id cardRowID);
|
||||
nsresult NotifyListEntryChange(PRUint32 abCode, nsIAbDirectory *dir, nsIAddrDBListener *instigator);
|
||||
|
||||
nsresult GetCollationKeyGenerator();
|
||||
nsresult AddLowercaseColumn(nsIMdbRow * row, mdb_token columnToken, const char* utf8String);
|
||||
nsresult GetRowFromAttribute(const char *aName, const char *aUTF8Value, PRBool aCaseInsensitive, nsIMdbRow **aCardRow);
|
||||
|
||||
static nsVoidArray/*<nsAddrDatabase>*/ * GetDBCache();
|
||||
static nsVoidArray/*<nsAddrDatabase>*/ * m_dbCache;
|
||||
@ -348,11 +312,10 @@ protected:
|
||||
nsresult InitNewDB();
|
||||
nsresult InitMDBInfo();
|
||||
nsresult InitPabTable();
|
||||
nsresult InitAnonymousTable();
|
||||
|
||||
nsresult InitLastRecorKey();
|
||||
nsresult GetDataRow(nsIMdbRow **pDataRow);
|
||||
nsresult GetLastRecorKey();
|
||||
nsresult GetLastRecordKey();
|
||||
nsresult UpdateLastRecordKey();
|
||||
nsresult CheckAndUpdateRecordKey();
|
||||
nsresult UpdateLowercaseEmailListName();
|
||||
@ -373,15 +336,6 @@ protected:
|
||||
PRBool m_mdbTokensInitialized;
|
||||
nsVoidArray /*<nsIAddrDBListener>*/ *m_ChangeListeners;
|
||||
|
||||
nsIMdbTable *m_mdbAnonymousTable;
|
||||
mdb_kind m_AnonymousTableKind;
|
||||
nsVoidArray* m_pAnonymousStrAttributes;
|
||||
nsVoidArray* m_pAnonymousStrValues;
|
||||
nsVoidArray* m_pAnonymousIntAttributes;
|
||||
nsVoidArray* m_pAnonymousIntValues;
|
||||
nsVoidArray* m_pAnonymousBoolAttributes;
|
||||
nsVoidArray* m_pAnonymousBoolValues;
|
||||
|
||||
mdb_kind m_PabTableKind;
|
||||
mdb_kind m_MailListTableKind;
|
||||
|
||||
@ -443,8 +397,6 @@ protected:
|
||||
PRUint32 m_LastRecordKey;
|
||||
nsIAbDirectory* m_dbDirectory;
|
||||
|
||||
nsCOMPtr<nsICollation> m_collationKeyGenerator;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,9 @@
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsICmdLineHandler.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICollation.h"
|
||||
|
||||
class nsILocalFile;
|
||||
class nsIAbDirectory;
|
||||
|
||||
#define NC_RDF_NEWABCARD "http://home.netscape.com/NC-rdf#NewCard"
|
||||
#define NC_RDF_DELETE "http://home.netscape.com/NC-rdf#Delete"
|
||||
@ -73,8 +75,9 @@ protected:
|
||||
nsresult GetAbDatabaseFromFile(char* pDbFile, nsIAddrDatabase **db);
|
||||
|
||||
private:
|
||||
nsIDocShell *mDocShell; // weak reference
|
||||
nsCOMPtr<nsICollation> mCollationKeyGenerator;
|
||||
nsIDocShell *mDocShell; // weak reference
|
||||
nsresult ExportDirectory(nsIAbDirectory *aDirectory, const char *aDelim, PRUint32 aDelimLen, nsILocalFile *aLocalFile);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,736 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCardDataSource.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "prprf.h"
|
||||
#include "prlog.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kAbCardDataSourceCID, NS_ABCARDDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_DisplayName = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Name = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Nickname = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_PrimaryEmail = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_SecondEmail = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_WorkPhone = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_HomePhone = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Fax = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Pager = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Cellular = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Title = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Department = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Organization = nsnull;
|
||||
|
||||
//for locale sorting,
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_DisplayNameCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_NameCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_NicknameCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_PrimaryEmailCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_SecondEmailCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_WorkPhoneCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_HomePhoneCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_FaxCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_PagerCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_CellularCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_TitleCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_DepartmentCollation = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_CompanyCollation = nsnull;
|
||||
|
||||
// commands
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_Delete = nsnull;
|
||||
nsIRDFResource* nsAbCardDataSource::kNC_NewCard = nsnull;
|
||||
|
||||
|
||||
#define NC_RDF_DISPLAYNAME "http://home.netscape.com/NC-rdf#DisplayName"
|
||||
#define NC_RDF_NAME "http://home.netscape.com/NC-rdf#Name"
|
||||
#define NC_RDF_NICKNAME "http://home.netscape.com/NC-rdf#Nickname"
|
||||
#define NC_RDF_PRIMARYEMAIL "http://home.netscape.com/NC-rdf#PrimaryEmail"
|
||||
#define NC_RDF_SECONDEMAIL "http://home.netscape.com/NC-rdf#SecondEmail"
|
||||
#define NC_RDF_WORKPHONE "http://home.netscape.com/NC-rdf#WorkPhone"
|
||||
#define NC_RDF_HOMEPHONE "http://home.netscape.com/NC-rdf#HomePhone"
|
||||
#define NC_RDF_FAX "http://home.netscape.com/NC-rdf#Fax"
|
||||
#define NC_RDF_PAGER "http://home.netscape.com/NC-rdf#Pager"
|
||||
#define NC_RDF_CELLULAR "http://home.netscape.com/NC-rdf#Cellular"
|
||||
#define NC_RDF_TITLE "http://home.netscape.com/NC-rdf#Title"
|
||||
#define NC_RDF_DEPARTMENT "http://home.netscape.com/NC-rdf#Department"
|
||||
#define NC_RDF_ORGANIZATION "http://home.netscape.com/NC-rdf#Company"
|
||||
|
||||
#define NC_RDF_DISPLAYNAME_SORT "http://home.netscape.com/NC-rdf#DisplayName?collation=true"
|
||||
#define NC_RDF_NAME_SORT "http://home.netscape.com/NC-rdf#Name?collation=true"
|
||||
#define NC_RDF_NICKNAME_SORT "http://home.netscape.com/NC-rdf#Nickname?collation=true"
|
||||
#define NC_RDF_PRIMARYEMAIL_SORT "http://home.netscape.com/NC-rdf#PrimaryEmail?collation=true"
|
||||
#define NC_RDF_SECONDEMAIL_SORT "http://home.netscape.com/NC-rdf#SecondEmail?collation=true"
|
||||
#define NC_RDF_WORKPHONE_SORT "http://home.netscape.com/NC-rdf#WorkPhone?collation=true"
|
||||
#define NC_RDF_HOMEPHONE_SORT "http://home.netscape.com/NC-rdf#HomePhone?collation=true"
|
||||
#define NC_RDF_FAX_SORT "http://home.netscape.com/NC-rdf#Fax?collation=true"
|
||||
#define NC_RDF_PAGER_SORT "http://home.netscape.com/NC-rdf#Pager?collation=true"
|
||||
#define NC_RDF_CELLULAR_SORT "http://home.netscape.com/NC-rdf#Cellular?collation=true"
|
||||
#define NC_RDF_TITLE_SORT "http://home.netscape.com/NC-rdf#Title?collation=true"
|
||||
#define NC_RDF_DEPARTMENT_SORT "http://home.netscape.com/NC-rdf#Department?collation=true"
|
||||
#define NC_RDF_ORGANIZATION_SORT "http://home.netscape.com/NC-rdf#Company?collation=true"
|
||||
|
||||
//Commands
|
||||
#define NC_RDF_DELETE "http://home.netscape.com/NC-rdf#Delete"
|
||||
#define NC_RDF_NEWCADR "http://home.netscape.com/NC-rdf#NewCard"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsAbCardDataSource::nsAbCardDataSource():
|
||||
mInitialized(PR_FALSE),
|
||||
mRDFService(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsAbCardDataSource::~nsAbCardDataSource (void)
|
||||
{
|
||||
if (mRDFService)
|
||||
{
|
||||
mRDFService->UnregisterDataSource(this);
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||
mRDFService = nsnull;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
abSession->RemoveAddressBookListener(this);
|
||||
|
||||
nsrefcnt refcnt;
|
||||
|
||||
if (kNC_DisplayName)
|
||||
NS_RELEASE2(kNC_DisplayName, refcnt);
|
||||
if (kNC_Name)
|
||||
NS_RELEASE2(kNC_Name, refcnt);
|
||||
if (kNC_Nickname)
|
||||
NS_RELEASE2(kNC_Nickname, refcnt);
|
||||
if (kNC_PrimaryEmail)
|
||||
NS_RELEASE2(kNC_PrimaryEmail, refcnt);
|
||||
if (kNC_SecondEmail)
|
||||
NS_RELEASE2(kNC_SecondEmail, refcnt);
|
||||
if (kNC_WorkPhone)
|
||||
NS_RELEASE2(kNC_WorkPhone, refcnt);
|
||||
if (kNC_HomePhone)
|
||||
NS_RELEASE2(kNC_HomePhone, refcnt);
|
||||
if (kNC_Fax)
|
||||
NS_RELEASE2(kNC_Fax, refcnt);
|
||||
if (kNC_Pager)
|
||||
NS_RELEASE2(kNC_Pager, refcnt);
|
||||
if (kNC_Cellular)
|
||||
NS_RELEASE2(kNC_Cellular, refcnt);
|
||||
if (kNC_Title)
|
||||
NS_RELEASE2(kNC_Title, refcnt);
|
||||
if (kNC_Department)
|
||||
NS_RELEASE2(kNC_Department, refcnt);
|
||||
if (kNC_Organization)
|
||||
NS_RELEASE2(kNC_Organization, refcnt);
|
||||
|
||||
if (kNC_DisplayNameCollation)
|
||||
NS_RELEASE2(kNC_DisplayNameCollation, refcnt);
|
||||
if (kNC_NameCollation)
|
||||
NS_RELEASE2(kNC_NameCollation, refcnt);
|
||||
if (kNC_NicknameCollation)
|
||||
NS_RELEASE2(kNC_NicknameCollation, refcnt);
|
||||
if (kNC_PrimaryEmailCollation)
|
||||
NS_RELEASE2(kNC_PrimaryEmailCollation, refcnt);
|
||||
if (kNC_SecondEmailCollation)
|
||||
NS_RELEASE2(kNC_SecondEmailCollation, refcnt);
|
||||
if (kNC_WorkPhoneCollation)
|
||||
NS_RELEASE2(kNC_WorkPhoneCollation, refcnt);
|
||||
if (kNC_HomePhoneCollation)
|
||||
NS_RELEASE2(kNC_HomePhoneCollation, refcnt);
|
||||
if (kNC_FaxCollation)
|
||||
NS_RELEASE2(kNC_FaxCollation, refcnt);
|
||||
if (kNC_PagerCollation)
|
||||
NS_RELEASE2(kNC_PagerCollation, refcnt);
|
||||
if (kNC_CellularCollation)
|
||||
NS_RELEASE2(kNC_CellularCollation, refcnt);
|
||||
if (kNC_TitleCollation)
|
||||
NS_RELEASE2(kNC_TitleCollation, refcnt);
|
||||
if (kNC_DepartmentCollation)
|
||||
NS_RELEASE2(kNC_DepartmentCollation, refcnt);
|
||||
if (kNC_CompanyCollation)
|
||||
NS_RELEASE2(kNC_CompanyCollation, refcnt);
|
||||
|
||||
if (kNC_Delete)
|
||||
NS_RELEASE2(kNC_Delete, refcnt);
|
||||
if (kNC_NewCard)
|
||||
NS_RELEASE2(kNC_NewCard, refcnt);
|
||||
|
||||
}
|
||||
|
||||
nsresult nsAbCardDataSource::Init()
|
||||
{
|
||||
if (mInitialized)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> abSession =
|
||||
do_GetService(kAddrBookSessionCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
abSession->AddAddressBookListener(this);
|
||||
|
||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||
|
||||
if (! kNC_DisplayName)
|
||||
{
|
||||
mRDFService->GetResource(NC_RDF_DISPLAYNAME, &kNC_DisplayName);
|
||||
mRDFService->GetResource(NC_RDF_NAME, &kNC_Name);
|
||||
mRDFService->GetResource(NC_RDF_NICKNAME, &kNC_Nickname);
|
||||
mRDFService->GetResource(NC_RDF_PRIMARYEMAIL, &kNC_PrimaryEmail);
|
||||
mRDFService->GetResource(NC_RDF_SECONDEMAIL, &kNC_SecondEmail);
|
||||
mRDFService->GetResource(NC_RDF_WORKPHONE, &kNC_WorkPhone);
|
||||
mRDFService->GetResource(NC_RDF_HOMEPHONE, &kNC_HomePhone);
|
||||
mRDFService->GetResource(NC_RDF_FAX, &kNC_Fax);
|
||||
mRDFService->GetResource(NC_RDF_PAGER, &kNC_Pager);
|
||||
mRDFService->GetResource(NC_RDF_CELLULAR, &kNC_Cellular);
|
||||
mRDFService->GetResource(NC_RDF_TITLE, &kNC_Title);
|
||||
mRDFService->GetResource(NC_RDF_DEPARTMENT, &kNC_Department);
|
||||
mRDFService->GetResource(NC_RDF_ORGANIZATION, &kNC_Organization);
|
||||
|
||||
mRDFService->GetResource(NC_RDF_DISPLAYNAME_SORT, &kNC_DisplayNameCollation);
|
||||
mRDFService->GetResource(NC_RDF_NAME_SORT, &kNC_NameCollation);
|
||||
mRDFService->GetResource(NC_RDF_NICKNAME_SORT, &kNC_NicknameCollation);
|
||||
mRDFService->GetResource(NC_RDF_PRIMARYEMAIL_SORT, &kNC_PrimaryEmailCollation);
|
||||
mRDFService->GetResource(NC_RDF_SECONDEMAIL_SORT, &kNC_SecondEmailCollation);
|
||||
mRDFService->GetResource(NC_RDF_WORKPHONE_SORT, &kNC_WorkPhoneCollation);
|
||||
mRDFService->GetResource(NC_RDF_HOMEPHONE_SORT, &kNC_HomePhoneCollation);
|
||||
mRDFService->GetResource(NC_RDF_FAX_SORT, &kNC_FaxCollation);
|
||||
mRDFService->GetResource(NC_RDF_PAGER_SORT, &kNC_PagerCollation);
|
||||
mRDFService->GetResource(NC_RDF_CELLULAR_SORT, &kNC_CellularCollation);
|
||||
mRDFService->GetResource(NC_RDF_TITLE_SORT, &kNC_TitleCollation);
|
||||
mRDFService->GetResource(NC_RDF_DEPARTMENT_SORT, &kNC_DepartmentCollation);
|
||||
mRDFService->GetResource(NC_RDF_ORGANIZATION_SORT, &kNC_CompanyCollation);
|
||||
|
||||
mRDFService->GetResource(NC_RDF_DELETE, &kNC_Delete);
|
||||
mRDFService->GetResource(NC_RDF_NEWCADR, &kNC_NewCard);
|
||||
}
|
||||
mInitialized = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsAbCardDataSource, nsAbRDFDataSource)
|
||||
NS_IMPL_RELEASE_INHERITED(nsAbCardDataSource, nsAbRDFDataSource)
|
||||
|
||||
NS_IMETHODIMP nsAbCardDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if(iid.Equals(NS_GET_IID(nsIAbListener)))
|
||||
{
|
||||
*result = NS_STATIC_CAST(nsIAbListener*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return nsAbRDFDataSource::QueryInterface(iid, result);
|
||||
}
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHODIMP nsAbCardDataSource::GetURI(char* *uri)
|
||||
{
|
||||
if ((*uri = nsCRT::strdup("rdf:addresscard")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardDataSource::GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target)
|
||||
{
|
||||
nsresult rv = NS_RDF_NO_VALUE;
|
||||
|
||||
// we only have positive assertions in the mail data source.
|
||||
if (! tv)
|
||||
return NS_RDF_NO_VALUE;
|
||||
|
||||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv));
|
||||
if (NS_SUCCEEDED(rv) && card) {
|
||||
rv = createCardNode(card, property, target);
|
||||
}
|
||||
else
|
||||
return NS_RDF_NO_VALUE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAbCardDataSource::GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** targets)
|
||||
{
|
||||
nsresult rv = NS_RDF_NO_VALUE;
|
||||
|
||||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv));
|
||||
if (NS_SUCCEEDED(rv) && card)
|
||||
{
|
||||
if((kNC_DisplayName == property) || (kNC_Name == property) ||
|
||||
(kNC_Nickname == property) || (kNC_PrimaryEmail == property) ||
|
||||
(kNC_SecondEmail == property) || (kNC_WorkPhone == property) ||
|
||||
(kNC_HomePhone == property) || (kNC_Fax == property) ||
|
||||
(kNC_Pager == property) || (kNC_Cellular == property) ||
|
||||
(kNC_Title == property) || (kNC_Department == property) ||
|
||||
(kNC_Organization == property))
|
||||
{
|
||||
nsSingletonEnumerator* cursor =
|
||||
new nsSingletonEnumerator(property);
|
||||
if (cursor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(cursor);
|
||||
*targets = cursor;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//create empty cursor
|
||||
nsCOMPtr<nsISupportsArray> assertions;
|
||||
NS_NewISupportsArray(getter_AddRefs(assertions));
|
||||
nsArrayEnumerator* cursor =
|
||||
new nsArrayEnumerator(assertions);
|
||||
if(cursor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(cursor);
|
||||
*targets = cursor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NewEmptyEnumerator(targets);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardDataSource::HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
return DoCardHasAssertion(card, property, target, tv, hasAssertion);
|
||||
else
|
||||
*hasAssertion = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbCardDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(aSource, &rv));
|
||||
if (NS_SUCCEEDED(rv) && card) {
|
||||
*result = (aArc == kNC_DisplayName ||
|
||||
aArc == kNC_Name ||
|
||||
aArc == kNC_Nickname ||
|
||||
aArc == kNC_PrimaryEmail ||
|
||||
aArc == kNC_SecondEmail ||
|
||||
aArc == kNC_WorkPhone ||
|
||||
aArc == kNC_HomePhone ||
|
||||
aArc == kNC_Fax ||
|
||||
aArc == kNC_Pager ||
|
||||
aArc == kNC_Cellular ||
|
||||
aArc == kNC_Title ||
|
||||
aArc == kNC_Department ||
|
||||
aArc == kNC_Organization);
|
||||
}
|
||||
else {
|
||||
*result = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardDataSource::ArcLabelsOut(nsIRDFResource* source,
|
||||
nsISimpleEnumerator** labels)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> arcs;
|
||||
nsresult rv = NS_RDF_NO_VALUE;
|
||||
|
||||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv));
|
||||
if (NS_SUCCEEDED(rv) && card) {
|
||||
// fflush(stdout); // huh?
|
||||
rv = getCardArcLabelsOut(card, getter_AddRefs(arcs));
|
||||
}
|
||||
else {
|
||||
// how to return an empty cursor?
|
||||
// for now return a 0-length nsISupportsArray
|
||||
NS_NewISupportsArray(getter_AddRefs(arcs));
|
||||
}
|
||||
|
||||
nsArrayEnumerator* cursor =
|
||||
new nsArrayEnumerator(arcs);
|
||||
|
||||
if (cursor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(cursor);
|
||||
*labels = cursor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbCardDataSource::getCardArcLabelsOut(nsIAbCard *card,
|
||||
nsISupportsArray **arcs)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = NS_NewISupportsArray(arcs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
(*arcs)->AppendElement(kNC_DisplayName);
|
||||
(*arcs)->AppendElement(kNC_Name);
|
||||
(*arcs)->AppendElement(kNC_Nickname);
|
||||
(*arcs)->AppendElement(kNC_PrimaryEmail);
|
||||
(*arcs)->AppendElement(kNC_SecondEmail);
|
||||
(*arcs)->AppendElement(kNC_WorkPhone);
|
||||
(*arcs)->AppendElement(kNC_HomePhone);
|
||||
(*arcs)->AppendElement(kNC_Fax);
|
||||
(*arcs)->AppendElement(kNC_Pager);
|
||||
(*arcs)->AppendElement(kNC_Cellular);
|
||||
(*arcs)->AppendElement(kNC_Title);
|
||||
(*arcs)->AppendElement(kNC_Department);
|
||||
(*arcs)->AppendElement(kNC_Organization);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbCardDataSource::GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupportsArray> cmds;
|
||||
|
||||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(cmds));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
cmds->AppendElement(kNC_Delete);
|
||||
cmds->AppendElement(kNC_NewCard);
|
||||
}
|
||||
|
||||
if (cmds != nsnull)
|
||||
return cmds->Enumerate(commands);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbCardDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
|
||||
PRBool* aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAbCard> card;
|
||||
|
||||
PRUint32 i, cnt;
|
||||
rv = aSources->Count(&cnt);
|
||||
for (i = 0; i < cnt; i++) {
|
||||
nsCOMPtr<nsISupports> source = getter_AddRefs(aSources->ElementAt(i));
|
||||
card = do_QueryInterface(source, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// we don't care about the arguments -- card commands are always enabled
|
||||
if (!((aCommand == kNC_Delete) ||
|
||||
(aCommand == kNC_NewCard))) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
*aResult = PR_TRUE;
|
||||
return NS_OK; // succeeded for all sources
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbCardDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// XXX need to handle batching of command applied to all sources
|
||||
|
||||
PRUint32 i, cnt;
|
||||
rv = aSources->Count(&cnt);
|
||||
for (i = 0; i < cnt; i++)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(aSources->ElementAt(i));
|
||||
nsCOMPtr<nsIAbCard> card = do_QueryInterface(supports, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
if ((aCommand == kNC_Delete))
|
||||
rv = DoDeleteFromCard(card, aArguments);
|
||||
else if((aCommand == kNC_NewCard))
|
||||
rv = DoNewCard(card, aArguments);
|
||||
}
|
||||
}
|
||||
//for the moment return NS_OK, because failure stops entire DoCommand process.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardDataSource::OnItemAdded(nsISupports *parentDirectory, nsISupports *item)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardDataSource::OnItemRemoved(nsISupports *parentDirectory, nsISupports *item)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardDataSource::OnItemPropertyChanged(nsISupports *item, const char *property,
|
||||
const PRUnichar *oldValue, const PRUnichar *newValue)
|
||||
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> resource(do_QueryInterface(item, &rv));
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
if(PL_strcmp("DisplayName", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_DisplayName, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("Name", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_Name, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("NickName", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_Nickname, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("PrimaryEmail", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_PrimaryEmail, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("SecondEmail", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_SecondEmail, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("WorkPhone", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_WorkPhone, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("HomePhone", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_HomePhone, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("FaxNumber", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_Fax, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("PagerNumber", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_Pager, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("CellularNumber", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_Cellular, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("JobTitle", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_Title, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("Department", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_Department, oldValue, newValue);
|
||||
}
|
||||
if(PL_strcmp("Company", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_Organization, oldValue, newValue);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbCardDataSource::createCardNode(nsIAbCard* card,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode** target)
|
||||
{
|
||||
PRUnichar *name = nsnull;
|
||||
nsresult rv = NS_RDF_NO_VALUE;
|
||||
|
||||
if ((kNC_DisplayName == property))
|
||||
rv = card->GetDisplayName(&name);
|
||||
else if ((kNC_Name== property))
|
||||
rv = card->GetName(&name);
|
||||
else if ((kNC_Nickname == property))
|
||||
rv = card->GetNickName(&name);
|
||||
else if ((kNC_PrimaryEmail == property))
|
||||
rv = card->GetPrimaryEmail(&name);
|
||||
else if ((kNC_SecondEmail == property))
|
||||
rv = card->GetSecondEmail(&name);
|
||||
else if ((kNC_WorkPhone == property))
|
||||
rv = card->GetWorkPhone(&name);
|
||||
else if ((kNC_HomePhone == property))
|
||||
rv = card->GetHomePhone(&name);
|
||||
else if ((kNC_Fax == property))
|
||||
rv = card->GetFaxNumber(&name);
|
||||
else if ((kNC_Pager == property))
|
||||
rv = card->GetPagerNumber(&name);
|
||||
else if ((kNC_Cellular == property))
|
||||
rv = card->GetCellularNumber(&name);
|
||||
else if ((kNC_Title == property))
|
||||
rv = card->GetJobTitle(&name);
|
||||
else if ((kNC_Department == property))
|
||||
rv = card->GetDepartment(&name);
|
||||
else if ((kNC_Organization == property))
|
||||
rv = card->GetCompany(&name);
|
||||
else
|
||||
{
|
||||
PRUnichar *tempStr = nsnull;
|
||||
if (kNC_DisplayNameCollation == property)
|
||||
rv = card->GetDisplayName(&tempStr);
|
||||
else if (kNC_NameCollation == property)
|
||||
rv = card->GetName(&tempStr);
|
||||
else if (kNC_NicknameCollation == property)
|
||||
rv = card->GetNickName(&tempStr);
|
||||
else if (kNC_PrimaryEmailCollation == property)
|
||||
rv = card->GetPrimaryEmail(&tempStr);
|
||||
else if (kNC_SecondEmailCollation == property)
|
||||
rv = card->GetSecondEmail(&tempStr);
|
||||
else if (kNC_WorkPhoneCollation == property)
|
||||
rv = card->GetWorkPhone(&tempStr);
|
||||
else if (kNC_HomePhoneCollation == property)
|
||||
rv = card->GetHomePhone(&tempStr);
|
||||
else if (kNC_FaxCollation == property)
|
||||
rv = card->GetFaxNumber(&tempStr);
|
||||
else if (kNC_PagerCollation == property)
|
||||
rv = card->GetPagerNumber(&tempStr);
|
||||
else if (kNC_CellularCollation == property)
|
||||
rv = card->GetCellularNumber(&tempStr);
|
||||
else if (kNC_TitleCollation == property)
|
||||
rv = card->GetJobTitle(&tempStr);
|
||||
else if (kNC_DepartmentCollation == property)
|
||||
rv = card->GetDepartment(&tempStr);
|
||||
else if (kNC_CompanyCollation == property)
|
||||
rv = card->GetCompany(&tempStr);
|
||||
if (tempStr)
|
||||
{
|
||||
rv = card->GetCollationKey(tempStr, &name);
|
||||
nsCRT::free(tempStr);
|
||||
}
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (name)
|
||||
{
|
||||
nsString nameString(name);
|
||||
createNode(nameString, target);
|
||||
nsCRT::free(name);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbCardDataSource::DoDeleteFromCard(nsIAbCard *card, nsISupportsArray *arguments)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbCardDataSource::DoNewCard(nsIAbCard *card, nsISupportsArray *arguments)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsISupports> elem = getter_AddRefs(arguments->ElementAt(0));
|
||||
nsCOMPtr<nsIRDFLiteral> literal(do_QueryInterface(elem, &rv));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
PRUnichar *name;
|
||||
literal->GetValue(&name);
|
||||
nsString tempStr(name);
|
||||
nsMemory::Free(name);
|
||||
nsCAutoString nameStr; nameStr.AssignWithConversion(tempStr);
|
||||
|
||||
// rv = card->CreateNewCard(nameStr);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbCardDataSource::DoCardHasAssertion(nsIAbCard *card, nsIRDFResource *property, nsIRDFNode *target,
|
||||
PRBool tv, PRBool *hasAssertion)
|
||||
{
|
||||
*hasAssertion = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult NS_NewAbCardDataSource(const nsIID& iid, void **result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsAbCardDataSource* datasource = new nsAbCardDataSource();
|
||||
if (! datasource)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
rv = datasource->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
delete datasource;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return datasource->QueryInterface(iid, result);
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user