Bug 1636019 - Remove the remaining uses of nsIAbView, then remove it and nsAbView. r=mkmelin DONTBUILD
--HG-- extra : rebase_source : e2d174f67f6b4076efe41d825d59e6788c073ace extra : amend_source : 9edfca00c0a8ec215e6f44da91e46268ed411c97 extra : histedit_source : 017e647d7004678abc4390295b90e0b69c33a107
This commit is contained in:
Родитель
8fdf4621ed
Коммит
6a2f77e457
|
@ -172,26 +172,15 @@ function ComposeMessage(type, format, folder, messageArray) {
|
|||
case msgComposeType.New: // new message
|
||||
// dump("OpenComposeWindow with " + identity + "\n");
|
||||
|
||||
// If the addressbook sidebar panel is open and has focus, get
|
||||
// the selected addresses from it.
|
||||
if (
|
||||
document.commandDispatcher.focusedWindow &&
|
||||
document.commandDispatcher.focusedWindow.document.documentElement.hasAttribute(
|
||||
"selectedaddresses"
|
||||
)
|
||||
) {
|
||||
NewMessageToSelectedAddresses(type, format, identity);
|
||||
} else {
|
||||
MailServices.compose.OpenComposeWindow(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
type,
|
||||
format,
|
||||
identity,
|
||||
msgWindow
|
||||
);
|
||||
}
|
||||
MailServices.compose.OpenComposeWindow(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
type,
|
||||
format,
|
||||
identity,
|
||||
msgWindow
|
||||
);
|
||||
return;
|
||||
case msgComposeType.NewsPost:
|
||||
// dump("OpenComposeWindow with " + identity + " and " + newsgroup + "\n");
|
||||
|
@ -277,35 +266,6 @@ function ComposeMessage(type, format, folder, messageArray) {
|
|||
}
|
||||
/* eslint-enable complexity */
|
||||
|
||||
function NewMessageToSelectedAddresses(type, format, identity) {
|
||||
var abSidebarPanel = document.commandDispatcher.focusedWindow;
|
||||
var abResultsTree = abSidebarPanel.document.getElementById("abResultsTree");
|
||||
var abView = abResultsTree.view;
|
||||
abView = abView.QueryInterface(Ci.nsIAbView);
|
||||
var addresses = abView.selectedAddresses;
|
||||
var params = Cc[
|
||||
"@mozilla.org/messengercompose/composeparams;1"
|
||||
].createInstance(Ci.nsIMsgComposeParams);
|
||||
if (params) {
|
||||
params.type = type;
|
||||
params.format = format;
|
||||
params.identity = identity;
|
||||
var composeFields = Cc[
|
||||
"@mozilla.org/messengercompose/composefields;1"
|
||||
].createInstance(Ci.nsIMsgCompFields);
|
||||
if (composeFields) {
|
||||
let addressList = [];
|
||||
const nsISupportsString = Ci.nsISupportsString;
|
||||
for (let i = 0; i < addresses.length; i++) {
|
||||
addressList.push(addresses.queryElementAt(i, nsISupportsString).data);
|
||||
}
|
||||
composeFields.to = addressList.join(",");
|
||||
params.composeFields = composeFields;
|
||||
MailServices.compose.OpenComposeWindowWithParams(null, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Subscribe(preselectedMsgFolder) {
|
||||
window.openDialog(
|
||||
"chrome://messenger/content/subscribe.xhtml",
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
<window id="abContactsPanel"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
onload="AbPanelLoad();"
|
||||
onunload="AbPanelUnload();"
|
||||
selectedaddresses="true">
|
||||
onunload="AbPanelUnload();">
|
||||
|
||||
<stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
|
||||
|
||||
|
|
|
@ -435,11 +435,6 @@
|
|||
class="menuitem-iconic"/>
|
||||
|
||||
<menuseparator/>
|
||||
<!-- LOCALIZATION NOTE: set "hideSwapFnLnUI" to false in .dtd to enable the UI -->
|
||||
<menuitem label="&swapFirstNameLastNameCmd.label;"
|
||||
accesskey="&swapFirstNameLastNameCmd.accesskey;"
|
||||
hidden="&hideSwapFnLnUI;"
|
||||
oncommand="AbSwapFirstNameLastName()"/>
|
||||
<menuitem id="menu_properties"
|
||||
key="key_properties"
|
||||
command="cmd_properties"
|
||||
|
|
|
@ -98,21 +98,20 @@ add_task(async () => {
|
|||
}
|
||||
|
||||
function checkRows(...expectedCards) {
|
||||
abContactTree.view.QueryInterface(Ci.nsIAbView);
|
||||
Assert.equal(
|
||||
abContactTree.view.rowCount,
|
||||
abWindow.gAbView.rowCount,
|
||||
expectedCards.length,
|
||||
"rowCount correct"
|
||||
);
|
||||
for (let i = 0; i < expectedCards.length; i++) {
|
||||
if (expectedCards[i].isMailList) {
|
||||
Assert.equal(
|
||||
abContactTree.view.getCardFromRow(i).displayName,
|
||||
abWindow.gAbView.getCardFromRow(i).displayName,
|
||||
expectedCards[i].dirName
|
||||
);
|
||||
} else {
|
||||
Assert.equal(
|
||||
abContactTree.view.getCardFromRow(i).displayName,
|
||||
abWindow.gAbView.getCardFromRow(i).displayName,
|
||||
expectedCards[i].displayName
|
||||
);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ add_task(async () => {
|
|||
is(resultsTree.view.rowCount, expectedCards.length, "rowCount correct");
|
||||
for (let i = 0; i < expectedCards.length; i++) {
|
||||
is(
|
||||
resultsTree.view.QueryInterface(Ci.nsIAbView).getCardFromRow(i)
|
||||
.displayName,
|
||||
abWindow.gAbView.getCardFromRow(i).displayName,
|
||||
expectedCards[i].displayName,
|
||||
`row ${i} has the right contact`
|
||||
);
|
||||
|
|
|
@ -52,11 +52,6 @@
|
|||
<!ENTITY deleteListsCmd.label "Delete Lists">
|
||||
<!ENTITY deleteItemsCmd.label "Delete Items">
|
||||
<!ENTITY searchAddressesCmd.key "f">
|
||||
<!ENTITY swapFirstNameLastNameCmd.label "Swap First/Last Name">
|
||||
<!ENTITY swapFirstNameLastNameCmd.accesskey "w">
|
||||
<!-- LOCALIZATION NOTE (hideSwapFnLnUI) : DONT_TRANSLATE -->
|
||||
<!-- Swap FN/LN UI Set to "false" to show swap fn/ln UI -->
|
||||
<!ENTITY hideSwapFnLnUI "true">
|
||||
<!ENTITY propertiesMenu.label "Properties">
|
||||
<!ENTITY propertiesMenu.accesskey "i">
|
||||
<!ENTITY propertiesCmd.key "i">
|
||||
|
|
|
@ -36,18 +36,19 @@ var kCardsOnly = 4;
|
|||
|
||||
// Global Variables
|
||||
|
||||
// gAbView holds an object with an nsIAbView interface
|
||||
var gAbView = null;
|
||||
// Holds a reference to the "abResultsTree" document element. Initially
|
||||
// set up by SetAbView.
|
||||
var gAbResultsTree = null;
|
||||
// gAbView is the current value of gAbResultsTree.view, without passing
|
||||
// through XPCOM, so we can access extra functions if necessary.
|
||||
var gAbView = null;
|
||||
|
||||
function SetAbView(aURI, aSearchQuery) {
|
||||
// If we don't have a URI, just clear the view and leave everything else
|
||||
// alone.
|
||||
if (!aURI) {
|
||||
if (gAbView) {
|
||||
gAbView.clearView();
|
||||
CloseAbView();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -271,12 +272,6 @@ function GetSelectedRows() {
|
|||
return selectedRows;
|
||||
}
|
||||
|
||||
function AbSwapFirstNameLastName() {
|
||||
if (gAbView) {
|
||||
gAbView.swapFirstNameLastName();
|
||||
}
|
||||
}
|
||||
|
||||
function AbEditSelectedCard() {
|
||||
AbEditCard(GetSelectedCard());
|
||||
}
|
||||
|
|
|
@ -30,12 +30,13 @@ function ABView(directory, searchQuery, listener, sortColumn, sortDirection) {
|
|||
ABView.prototype = {
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
Ci.nsITreeView,
|
||||
Ci.nsIAbView,
|
||||
Ci.nsIAbDirSearchListener,
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference,
|
||||
]),
|
||||
|
||||
directory: null,
|
||||
listener: null,
|
||||
_notifications: [
|
||||
"addrbook-contact-created",
|
||||
"addrbook-contact-deleted",
|
||||
|
@ -43,31 +44,14 @@ ABView.prototype = {
|
|||
"addrbook-list-member-removed",
|
||||
],
|
||||
|
||||
// nsITreeView
|
||||
|
||||
selectionChanged() {
|
||||
if (this.listener) {
|
||||
this.listener.onSelectionChanged();
|
||||
}
|
||||
},
|
||||
setTree(tree) {
|
||||
this.tree = tree;
|
||||
for (let topic of this._notifications) {
|
||||
if (tree) {
|
||||
Services.obs.addObserver(this, topic, true);
|
||||
} else {
|
||||
Services.obs.removeObserver(this, topic);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// nsIAbView
|
||||
sortColumn: "",
|
||||
sortDirection: "",
|
||||
|
||||
deleteSelectedCards() {
|
||||
let directoryMap = new Map();
|
||||
for (let i = 0; i < this.selection.getRangeCount(); i++) {
|
||||
let start = {},
|
||||
finish = {};
|
||||
let start = {};
|
||||
let finish = {};
|
||||
this.selection.getRangeAt(i, start, finish);
|
||||
for (let j = start.value; j <= finish.value; j++) {
|
||||
let card = this.getCardFromRow(j);
|
||||
|
@ -97,13 +81,9 @@ ABView.prototype = {
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
getCardFromRow(row) {
|
||||
return this._rowMap[row] ? this._rowMap[row].card : null;
|
||||
},
|
||||
|
||||
sortColumn: "",
|
||||
sortDirection: "",
|
||||
sortBy(sortColumn, sortDirection, resort) {
|
||||
if (sortColumn == this.sortColumn && !resort) {
|
||||
if (sortDirection == this.sortDirection) {
|
||||
|
@ -128,6 +108,24 @@ ABView.prototype = {
|
|||
this.sortDirection = sortDirection;
|
||||
},
|
||||
|
||||
// nsITreeView
|
||||
|
||||
selectionChanged() {
|
||||
if (this.listener) {
|
||||
this.listener.onSelectionChanged();
|
||||
}
|
||||
},
|
||||
setTree(tree) {
|
||||
this.tree = tree;
|
||||
for (let topic of this._notifications) {
|
||||
if (tree) {
|
||||
Services.obs.addObserver(this, topic, true);
|
||||
} else {
|
||||
Services.obs.removeObserver(this, topic);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// nsIAbDirSearchListener
|
||||
|
||||
onSearchFoundCard(card) {
|
||||
|
|
|
@ -16,7 +16,6 @@ XPIDL_SOURCES += [
|
|||
'nsIAbLDIFService.idl',
|
||||
'nsIAbListener.idl',
|
||||
'nsIAbManager.idl',
|
||||
'nsIAbView.idl',
|
||||
'nsIAddbookUrl.idl',
|
||||
'nsIAddrDatabase.idl',
|
||||
'nsIMsgVCardService.idl',
|
||||
|
|
|
@ -332,16 +332,6 @@
|
|||
#define NS_ABLDAP_PROCESSCHANGELOGDATA_CONTRACTID \
|
||||
"@mozilla.org/addressbook/ldap-process-changelog-data;1"
|
||||
|
||||
// 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"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
//
|
||||
// nsAbOSXDirectory
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIAbCard;
|
||||
interface nsIAbDirectory;
|
||||
interface nsIArray;
|
||||
|
||||
/// Define a class using this interface to listen to updates from nsIAbView.
|
||||
[scriptable, uuid(79ad5d6e-1dd2-11b2-addd-f547dab50d75)]
|
||||
interface nsIAbViewListener : nsISupports
|
||||
{
|
||||
/// Called when the selection is changed in the tree
|
||||
void onSelectionChanged();
|
||||
|
||||
/// Called when the total count of cards is changed.
|
||||
void onCountChanged(in long total);
|
||||
};
|
||||
|
||||
/**
|
||||
* This interface and its associated nsAbView object provides an interface
|
||||
* to allow a tree to be associated with an address book, and the results
|
||||
* to be displayed in that tree.
|
||||
*
|
||||
* If you wish for the tree to display the results of a different address
|
||||
* book, then call setView again. There is no need to delete and recreate the
|
||||
* nsAbView object. If you wish to clear the view, then just call clearView.
|
||||
*/
|
||||
[scriptable, uuid(45e2fa9f-0b59-4090-a2fa-fb7042cf64a2)]
|
||||
interface nsIAbView : nsISupports
|
||||
{
|
||||
/**
|
||||
* Sets up the nsIAbView to look at the specified directory. This may be
|
||||
* called multiple times.
|
||||
*
|
||||
* @param aDirectory The directory to search, this may be a directory
|
||||
* with a query string.
|
||||
* @param aViewListener An optional listener.
|
||||
* @param aSortColumn The column to sort by. See the xul element with
|
||||
* id abResultsTreeCols for possible values.
|
||||
* @param aSortDirection The sort direction to use ("ascending"/"descending")
|
||||
* @return The actual sortColumn (various switching of apps
|
||||
* could cause the persisted sortColumn to be bogus).
|
||||
*/
|
||||
AString setView(in nsIAbDirectory aAddressBook,
|
||||
in nsIAbViewListener aAbViewListener,
|
||||
in AString aSortColumn,
|
||||
in AString aSortDirection);
|
||||
|
||||
/**
|
||||
* Clears the view and releases any locally held copies of the address book
|
||||
* directory. This should be called when the view is no longer required, e.g.
|
||||
* on unload.
|
||||
*/
|
||||
void clearView();
|
||||
|
||||
/**
|
||||
* Sorts the tree by the specified parameters.
|
||||
*
|
||||
* @param aSortColumn The column to sort by. See the xul element with
|
||||
* id abResultsTreeCols for possible values.
|
||||
* @param aSortDirection The sort direction to use ("ascending"/"descending")
|
||||
* @param aResort The function DOES optimize for the case when sortColumn
|
||||
* and sortDirection is identical since the last call.
|
||||
* If an unconditional resort is needed, set this to true.
|
||||
*/
|
||||
void sortBy(in wstring aSortColumn, in wstring aSortDirection,
|
||||
[optional] in boolean aResort);
|
||||
|
||||
/// Returns the current sort column
|
||||
readonly attribute AString sortColumn;
|
||||
|
||||
/// Returns the current sort direction
|
||||
readonly attribute AString sortDirection;
|
||||
|
||||
/**
|
||||
* Returns the current directory that this view is hooked up to. May be
|
||||
* null if no directory has been set.
|
||||
*/
|
||||
readonly attribute nsIAbDirectory directory;
|
||||
|
||||
/**
|
||||
* Returns the card associated with the given row.
|
||||
*
|
||||
* @param aRow The row from which to return the card.
|
||||
* @return A card associated with the row, or null if row is not valid.
|
||||
*/
|
||||
nsIAbCard getCardFromRow(in long aRow);
|
||||
|
||||
/// Selects all rows in the view.
|
||||
void selectAll();
|
||||
|
||||
/// Deletes all the selected cards (no prompts are given).
|
||||
void deleteSelectedCards();
|
||||
|
||||
/**
|
||||
* Swaps the first and last name order, and updates the appropriate
|
||||
* preference.
|
||||
*/
|
||||
void swapFirstNameLastName();
|
||||
|
||||
/**
|
||||
* Returns an array of the currently selected addresses.
|
||||
*/
|
||||
readonly attribute nsIArray selectedAddresses;
|
||||
};
|
|
@ -19,7 +19,6 @@ SOURCES += [
|
|||
'nsAbDirProperty.cpp',
|
||||
'nsAbLDIFService.cpp',
|
||||
'nsAbQueryStringToExpression.cpp',
|
||||
'nsAbView.cpp',
|
||||
'nsAddbookProtocolHandler.cpp',
|
||||
'nsAddbookUrl.cpp',
|
||||
'nsAddrDatabase.cpp',
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,83 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef _nsAbView_H_
|
||||
#define _nsAbView_H_
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAbView.h"
|
||||
#include "nsITreeView.h"
|
||||
#include "mozilla/dom/XULTreeElement.h"
|
||||
#include "nsITreeSelection.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIAbDirectory.h"
|
||||
#include "nsICollation.h"
|
||||
#include "nsIAbListener.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
typedef struct AbCard {
|
||||
explicit AbCard(nsIAbCard *c) : card(c) {}
|
||||
nsCOMPtr<nsIAbCard> card;
|
||||
nsTArray<uint8_t> primaryCollationKey;
|
||||
nsTArray<uint8_t> secondaryCollationKey;
|
||||
} AbCard;
|
||||
|
||||
class nsAbView : public nsIAbView,
|
||||
public nsITreeView,
|
||||
public nsIAbListener,
|
||||
public nsIObserver {
|
||||
public:
|
||||
nsAbView();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIABVIEW
|
||||
NS_DECL_NSITREEVIEW
|
||||
NS_DECL_NSIABLISTENER
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
int32_t CompareCollationKeys(const nsTArray<uint8_t> &key1,
|
||||
const nsTArray<uint8_t> &key2);
|
||||
|
||||
private:
|
||||
virtual ~nsAbView();
|
||||
nsresult Initialize();
|
||||
int32_t FindIndexForInsert(AbCard *abcard);
|
||||
int32_t FindIndexForCard(nsIAbCard *card);
|
||||
nsresult GenerateCollationKeysForCard(const nsAString &colID, AbCard *abcard);
|
||||
nsresult InvalidateTree(int32_t row);
|
||||
nsresult RemoveCardAt(int32_t row);
|
||||
nsresult AddCard(AbCard *abcard, bool selectCardAfterAdding, int32_t *index);
|
||||
nsresult RemoveCardAndSelectNextCard(nsISupports *item);
|
||||
nsresult EnumerateCards();
|
||||
nsresult SetGeneratedNameFormatFromPrefs();
|
||||
nsresult GetSelectedCards(nsCOMPtr<nsIMutableArray> &aSelectedCards);
|
||||
nsresult ReselectCards(nsIArray *aCards, nsIAbCard *aIndexCard);
|
||||
nsresult GetCardValue(nsIAbCard *card, const nsAString &colID,
|
||||
nsAString &_retval);
|
||||
nsresult RefreshTree();
|
||||
|
||||
RefPtr<mozilla::dom::XULTreeElement> mTree;
|
||||
nsCOMPtr<nsITreeSelection> mTreeSelection;
|
||||
nsCOMPtr<nsIAbDirectory> mDirectory;
|
||||
nsTArray<AbCard *> mCards;
|
||||
nsString mSortColumn;
|
||||
nsString mSortDirection;
|
||||
nsCOMPtr<nsICollation> mCollationKeyGenerator;
|
||||
nsCOMPtr<nsIAbViewListener> mAbViewListener;
|
||||
nsCOMPtr<nsIStringBundle> mABBundle;
|
||||
|
||||
bool mInitialized;
|
||||
bool mIsAllDirectoryRootView;
|
||||
bool mSuppressSelectionChange;
|
||||
bool mSuppressCountChange;
|
||||
int32_t mGeneratedNameFormat;
|
||||
};
|
||||
|
||||
#endif /* _nsAbView_H_ */
|
|
@ -17,8 +17,6 @@
|
|||
#include "nsIAbDirectory.h"
|
||||
#include "nsIAbManager.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIAbView.h"
|
||||
#include "nsITreeView.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIAsyncInputStream.h"
|
||||
|
@ -26,6 +24,8 @@
|
|||
#include "nsIPipe.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsCollationCID.h"
|
||||
#include "nsICollation.h"
|
||||
|
||||
nsAddbookProtocolHandler::nsAddbookProtocolHandler() {
|
||||
mAddbookOperation = nsIAddbookUrlOperation::InvalidUrl;
|
||||
|
@ -227,6 +227,62 @@ nsresult nsAddbookProtocolHandler::GeneratePrintOutput(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
typedef struct CardEnclosure {
|
||||
nsCOMPtr<nsIAbCard> card;
|
||||
nsString generatedName;
|
||||
} CardEnclosure;
|
||||
|
||||
class CardComparator {
|
||||
private:
|
||||
nsCOMPtr<nsICollation> mCollation;
|
||||
|
||||
int cmp(CardEnclosure a, CardEnclosure b) const {
|
||||
int32_t result;
|
||||
mCollation->CompareString(nsICollation::kCollationCaseInSensitive,
|
||||
a.generatedName, b.generatedName, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public:
|
||||
CardComparator() {
|
||||
nsCOMPtr<nsICollationFactory> factory =
|
||||
do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID);
|
||||
factory->CreateCollation(getter_AddRefs(mCollation));
|
||||
}
|
||||
|
||||
bool Equals(CardEnclosure a, CardEnclosure b) const { return cmp(a, b) == 0; }
|
||||
bool LessThan(CardEnclosure a, CardEnclosure b) const {
|
||||
return cmp(a, b) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
nsresult EnumerateCards(nsIAbDirectory *aDirectory,
|
||||
nsTArray<CardEnclosure> &aCards,
|
||||
nsIStringBundle *aBundle) {
|
||||
if (!aDirectory) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> cardsEnumerator;
|
||||
nsCOMPtr<nsIAbCard> card;
|
||||
|
||||
nsresult rv = aDirectory->GetChildCards(getter_AddRefs(cardsEnumerator));
|
||||
if (NS_SUCCEEDED(rv) && cardsEnumerator) {
|
||||
nsCOMPtr<nsISupports> item;
|
||||
bool more;
|
||||
while (NS_SUCCEEDED(cardsEnumerator->HasMoreElements(&more)) && more) {
|
||||
rv = cardsEnumerator->GetNext(getter_AddRefs(item));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIAbCard> card = do_QueryInterface(item);
|
||||
CardEnclosure enclosure = CardEnclosure();
|
||||
enclosure.card = card;
|
||||
card->GenerateName(0, aBundle, enclosure.generatedName);
|
||||
aCards.AppendElement(enclosure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAddbookProtocolHandler::BuildDirectoryXML(nsIAbDirectory *aDirectory,
|
||||
nsString &aOutput) {
|
||||
nsresult rv;
|
||||
|
@ -256,32 +312,45 @@ nsresult nsAddbookProtocolHandler::BuildDirectoryXML(nsIAbDirectory *aDirectory,
|
|||
}
|
||||
}
|
||||
|
||||
// create a view and init it with the generated name sort order. Then, iterate
|
||||
// over the view, getting the card for each row, and printing them.
|
||||
nsString sortColumn;
|
||||
nsCOMPtr<nsIAbView> view =
|
||||
do_CreateInstance("@mozilla.org/addressbook/abview;1", &rv);
|
||||
nsTArray<CardEnclosure> cards;
|
||||
if (aDirectory) {
|
||||
EnumerateCards(aDirectory, cards, bundle);
|
||||
} else {
|
||||
nsCOMPtr<nsIAbManager> abManager(
|
||||
do_GetService(NS_ABMANAGER_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = abManager->GetDirectories(getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
view->SetView(aDirectory, nullptr, NS_LITERAL_STRING("GeneratedName"),
|
||||
NS_LITERAL_STRING("ascending"), sortColumn);
|
||||
bool hasMore = false;
|
||||
nsCOMPtr<nsISupports> support;
|
||||
nsCOMPtr<nsIAbDirectory> directory;
|
||||
while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
|
||||
rv = enumerator->GetNext(getter_AddRefs(support));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
directory = do_QueryInterface(support, &rv);
|
||||
|
||||
int32_t numRows;
|
||||
nsCOMPtr<nsITreeView> treeView = do_QueryInterface(view, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
treeView->GetRowCount(&numRows);
|
||||
// If, for some reason, we are unable to get a directory, we continue.
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
for (int32_t row = 0; row < numRows; row++) {
|
||||
nsCOMPtr<nsIAbCard> card;
|
||||
view->GetCardFromRow(row, getter_AddRefs(card));
|
||||
rv = EnumerateCards(directory, cards, bundle);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
CardComparator cardComparator = CardComparator();
|
||||
cards.Sort(cardComparator);
|
||||
|
||||
for (CardEnclosure enclosure : cards) {
|
||||
bool isMailList;
|
||||
if (NS_FAILED(card->GetIsMailList(&isMailList)) || isMailList) {
|
||||
if (NS_FAILED(enclosure.card->GetIsMailList(&isMailList)) || isMailList) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCString xmlSubstr;
|
||||
|
||||
rv = card->TranslateTo(NS_LITERAL_CSTRING("xml"), xmlSubstr);
|
||||
rv = enclosure.card->TranslateTo(NS_LITERAL_CSTRING("xml"), xmlSubstr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aOutput.AppendLiteral("<separator/>");
|
||||
|
|
|
@ -121,7 +121,6 @@
|
|||
#include "nsAbDirectoryQuery.h"
|
||||
#include "nsAbBooleanExpression.h"
|
||||
#include "nsAbDirectoryQueryProxy.h"
|
||||
#include "nsAbView.h"
|
||||
#include "nsMsgVCardService.h"
|
||||
#include "nsAbLDIFService.h"
|
||||
|
||||
|
@ -460,7 +459,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPProcessReplicationData)
|
|||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryProxy)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbView)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgVCardService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDIFService)
|
||||
|
||||
|
@ -497,7 +495,6 @@ NS_DEFINE_NAMED_CID(NS_ABDIRECTORYQUERYPROXY_CID);
|
|||
NS_DEFINE_NAMED_CID(NS_ABOSXDIRECTORY_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_ABOSXCARD_CID);
|
||||
#endif
|
||||
NS_DEFINE_NAMED_CID(NS_ABVIEW_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_MSGVCARDSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_ABLDIFSERVICE_CID);
|
||||
|
||||
|
@ -918,7 +915,6 @@ const mozilla::Module::CIDEntry kMailNewsCIDs[] = {
|
|||
{&kNS_ABOSXDIRECTORY_CID, false, NULL, nsAbOSXDirectoryConstructor},
|
||||
{&kNS_ABOSXCARD_CID, false, NULL, nsAbOSXCardConstructor},
|
||||
#endif
|
||||
{&kNS_ABVIEW_CID, false, NULL, nsAbViewConstructor},
|
||||
{&kNS_MSGVCARDSERVICE_CID, false, NULL, nsMsgVCardServiceConstructor},
|
||||
{&kNS_ABLDIFSERVICE_CID, false, NULL, nsAbLDIFServiceConstructor},
|
||||
// Bayesian Filter Entries
|
||||
|
@ -1151,7 +1147,6 @@ const mozilla::Module::ContractIDEntry kMailNewsContracts[] = {
|
|||
{NS_ABOSXDIRECTORY_CONTRACTID, &kNS_ABOSXDIRECTORY_CID},
|
||||
{NS_ABOSXCARD_CONTRACTID, &kNS_ABOSXCARD_CID},
|
||||
#endif
|
||||
{NS_ABVIEW_CONTRACTID, &kNS_ABVIEW_CID},
|
||||
{NS_MSGVCARDSERVICE_CONTRACTID, &kNS_MSGVCARDSERVICE_CID},
|
||||
{NS_ABLDIFSERVICE_CONTRACTID, &kNS_ABLDIFSERVICE_CID},
|
||||
// Bayesian Filter Entries
|
||||
|
|
Загрузка…
Ссылка в новой задаче