Bug 1182460 - allow exporting all addressbooks. r=mkmelin, r=Ratty

This commit is contained in:
aceman 2016-02-09 00:50:26 +01:00
Родитель 6f2ff9ec01
Коммит 778c8ba8b2
5 изменённых файлов: 53 добавлений и 10 удалений

Просмотреть файл

@ -415,13 +415,47 @@ function AbPrintPreviewAddressBook()
AbPrintAddressBookInternal(true, Components.interfaces.nsIMsgPrintEngine.MNAB_PRINTPREVIEW_ADDRBOOK);
}
function AbExport()
{
try {
let selectedABURI = GetSelectedDirectory();
if (!selectedABURI) return;
/**
* Export the currently selected addressbook.
*/
function AbExportSelection() {
let selectedABURI = GetSelectedDirectory();
if (!selectedABURI)
return;
let directory = GetDirectoryFromURI(selectedABURI);
if (selectedABURI == (kAllDirectoryRoot + "?"))
return AbExportAll();
return AbExport(selectedABURI);
}
/**
* Export all found addressbooks, each in a separate file.
*/
function AbExportAll()
{
let directories = MailServices.ab.directories;
while (directories.hasMoreElements()) {
let directory = directories.getNext();
// Do not export LDAP ABs.
if (!directory.URI.startsWith(kLdapUrlPrefix))
AbExport(directory.URI);
}
}
/**
* Export the specified addressbook to a file.
*
* @param aSelectedABURI The URI if the addressbook to export.
*/
function AbExport(aSelectedABURI)
{
if (!aSelectedABURI)
return;
try {
let directory = GetDirectoryFromURI(aSelectedABURI);
MailServices.ab.exportAddressBook(window, directory);
}
catch (ex) {

Просмотреть файл

@ -552,7 +552,9 @@
<menuseparator/>
#endif
<menuitem label="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="toImport()"/>
<menuitem label="&exportCmd.label;" accesskey="&exportCmd.accesskey;" oncommand="AbExport()"/>
<menuitem label="&exportCmd.label;"
accesskey="&exportCmd.accesskey;"
oncommand="AbExportSelection();"/>
#ifndef XP_UNIX
<menuseparator id="prefSep"/>

Просмотреть файл

@ -130,7 +130,8 @@ abReplicationOfflineWarning=You must be online to perform LDAP replication.
abReplicationSaveSettings=Settings must be saved before a directory may be downloaded.
# For importing / exporting
ExportAddressBookTitle=Export Address Book
## LOCALIZATION NOTE (ExportAddressBookNameTitle): %S is the name of exported addressbook
ExportAddressBookNameTitle=Export Address Book - %S
LDIFFiles=LDIF
CSVFiles=Comma Separated
CSVFilesSysCharset=Comma Separated (System Charset)

Просмотреть файл

@ -545,8 +545,13 @@ NS_IMETHODIMP nsAbManager::ExportAddressBook(mozIDOMWindowProxy *aParentWin, nsI
rv = bundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);
nsString dirName;
aDirectory->GetDirName(dirName);
const char16_t *formatStrings[] = { dirName.get() };
nsString title;
rv = bundle->GetStringFromName(MOZ_UTF16("ExportAddressBookTitle"), getter_Copies(title));
rv = bundle->FormatStringFromName(MOZ_UTF16("ExportAddressBookNameTitle"), formatStrings,
ArrayLength(formatStrings), getter_Copies(title));
NS_ENSURE_SUCCESS(rv, rv);
rv = filePicker->Init(aParentWin, title, nsIFilePicker::modeSave);

Просмотреть файл

@ -123,7 +123,8 @@ abReplicationOfflineWarning=You must be online to perform LDAP replication.
abReplicationSaveSettings=Settings must be saved before a directory may be downloaded.
# For importing / exporting
ExportAddressBookTitle=Export Address Book
## LOCALIZATION NOTE (ExportAddressBookNameTitle): %S is the name of exported addressbook
ExportAddressBookNameTitle=Export Address Book - %S
LDIFFiles=LDIF
CSVFiles=Comma Separated
CSVFilesSysCharset=Comma Separated (System Charset)