fix for #43484 - sort the account manager and folder pane according to spec

r=putterman
This commit is contained in:
alecf%netscape.com 2000-08-10 22:02:52 +00:00
Родитель 17b1c02a54
Коммит 6c45e79b60
5 изменённых файлов: 71 добавлений и 13 удалений

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

@ -65,6 +65,11 @@ var setDefaultButton;
// called when the whole document loads
// perform initialization here
function onLoad() {
var selectedAccount;
if (window.arguments && window.arguments[0])
selectedServer = window.arguments[0].server;
accountArray = new Array;
RDF = Components.classes["component://netscape/rdf/rdf-service"].getService(Components.interfaces.nsIRDFService);
@ -81,21 +86,43 @@ function onLoad() {
deleteButton = document.getElementById("deleteButton");
setDefaultButton = document.getElementById("setDefaultButton");
selectFirstAccount()
sortAccountList(accounttree);
selectServer(selectedServer)
}
function selectFirstAccount()
{
var tree = document.getElementById("accounttree");
var firstItem = findFirstTreeItem(tree);
function sortAccountList(accounttree)
{
var xulSortService = Components.classes["component://netscape/rdf/xul-sort-service"].getService(Components.interfaces.nsIXULSortService);
xulSortService.Sort(accounttree, 'http://home.netscape.com/NC-rdf#FolderTreeName?sort=true', 'ascending');
}
if (firstItem) accounttree.selectItem(firstItem);
function selectServer(server)
{
var selectedItem;
if (server)
selectedItem = document.getElementById(server.serverURI);
if (!selectedItem)
selectedItem = getFirstAccount();
accounttree.selectItem(selectedItem);
var result = getServerIdAndPageIdFromTree(accounttree);
if (result) {
updateButtons(accounttree,result.serverId);
}
}
function getFirstAccount()
{
var tree = document.getElementById("accounttree");
var firstItem = findFirstTreeItem(tree);
return firstItem;
}
function findFirstTreeItem(tree) {
var children = tree.childNodes;

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

@ -36,10 +36,12 @@
<rule>
<treechildren flex="1">
<treeitem uri="..." open="true"
sort="rdf:http://home.netscape.com/NC-rdf#FolderTreeName?sort=true"
IsDefaultServer="rdf:http://home.netscape.com/NC-rdf#IsDefaultServer"
PageTag="rdf:http://home.netscape.com/NC-rdf#PageTag">
<treerow >
<treecell class="treecell-indent" value="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell class="treecell-indent"
value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</treerow>
</treeitem>
</treechildren>

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

@ -123,6 +123,13 @@ function msgOpenAccountWizard()
function MsgAccountManager()
{
var server;
try {
folderURI = GetSelectedFolderURI();
server = GetServer(folderURI);
} catch (ex) { /* functions might not be defined */}
window.openDialog("chrome://messenger/content/AccountManager.xul",
"AccountManager", "chrome,modal,resizable");
"AccountManager", "chrome,modal,resizable",
{ server: server });
}

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

@ -588,6 +588,7 @@ function GetSelectedMessage()
function GetServer(uri)
{
if (!uri) return null;
try {
var folder = GetMsgFolderFromUri(uri);
return folder.server;

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

@ -226,7 +226,6 @@ nsMsgAccountManagerDataSource::Init()
void nsMsgAccountManagerDataSource::Cleanup()
{
printf("*** AccountManager Datasource cleanup\n");
nsCOMPtr<nsIMsgAccountManager> am =
do_QueryReferent(mAccountManager);
@ -321,15 +320,37 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source,
// only answer for servers!
if (NS_FAILED(rv) || !server)
return NS_RDF_NO_VALUE;
// order is:
// - default account
// - <other servers>
// - Local Folders
// - news
PRInt32 accountNum;
nsCOMPtr<nsIMsgAccountManager> am =
do_QueryReferent(mAccountManager);
rv = am->FindServerIndex(server, &accountNum);
if (NS_FAILED(rv)) return rv;
if (isDefaultServer(server))
str = NS_LITERAL_STRING("0000");
else {
accountNum += 1000;
str.AppendInt(accountNum);
rv = am->FindServerIndex(server, &accountNum);
if (NS_FAILED(rv)) return rv;
// this is a hack for now - hardcode server order by type
nsXPIDLCString serverType;
server->GetType(getter_Copies(serverType));
if (nsCRT::strcasecmp(serverType, "none")==0)
accountNum += 2000;
else if (nsCRT::strcasecmp(serverType, "nntp")==0)
accountNum += 3000;
else
accountNum += 1000; // default is to appear at the top
str.AppendInt(accountNum);
}
}
// GetTargets() stuff - need to return a valid answer so that