133355 - adding fake free web mail account to folder pane - will only show up in commercial builds - r=bhuvan,sr=sspitzer,a=asa

This commit is contained in:
shliang%netscape.com 2002-04-10 11:57:39 +00:00
Родитель 60e32f6220
Коммит 98b807f0b0
11 изменённых файлов: 206 добавлений и 49 удалений

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

@ -192,6 +192,11 @@ function ChangeFolderByURI(uri, viewType, viewFlags, sortType, sortOrder)
HideAccountCentral();
}
if (gFakeAccountPageLoaded)
{
HideFakeAccountPage();
}
gCurrentLoadingFolderURI = uri;
gNextMessageAfterDelete = null; // forget what message to select, if any
@ -728,6 +733,8 @@ function FolderPaneSelectionChange()
if (gAccountCentralLoaded)
UpdateMailToolbar("gAccountCentralLoaded");
else if (gFakeAccountPageLoaded)
UpdateMailToolbar("gFakeAccountPageLoaded");
else {
document.getElementById('advancedButton').setAttribute("disabled" , !(IsCanSearchMessagesEnabled()));
ClearMessagePane();

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

@ -25,6 +25,7 @@
-->
<?xml-stylesheet href="chrome://messenger/skin/folderPane.css" type="text/css"?>
<?xml-stylesheet href="chrome://messenger/skin/fakeAccount.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://messenger/locale/folderpane.dtd">
@ -90,6 +91,9 @@
<binding subject="?member"
predicate="http://home.netscape.com/NC-rdf#TotalMessages"
object="?totalCount" />
<binding subject="?member"
predicate="http://home.netscape.com/NC-rdf#PageTitleFakeAccount"
object="?fakeAccount" />
</bindings>
<action>
@ -98,7 +102,7 @@
<treerow>
<treecell id="folderNameCell"
label="?folderTreeName"
properties="specialFolder-?specialFolder biffState-?biffState isServer-?isServer newMessages-?newMessages hasUnreadMessages-?hasUnreadMessages subfoldersHaveUnreadMessages-?subfoldersHaveUnreadMessages isSecure-?isSecure serverType-?serverType noSelect-?noSelect imapShared-?imapShared"/>
properties="specialFolder-?specialFolder biffState-?biffState isServer-?isServer newMessages-?newMessages hasUnreadMessages-?hasUnreadMessages subfoldersHaveUnreadMessages-?subfoldersHaveUnreadMessages isSecure-?isSecure serverType-?serverType noSelect-?noSelect imapShared-?imapShared fakeAccount-?fakeAccount"/>
<treecell label="?unreadCount"
properties="hasUnreadMessages-?hasUnreadMessages subfoldersHaveUnreadMessages-?subfoldersHaveUnreadMessages"/>
<treecell label="?totalCount"

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

@ -47,6 +47,9 @@ var FolderPaneController =
isCommandEnabled: function(command)
{
if (IsFakeAccount())
return false;
switch ( command )
{
case "cmd_selectAll":
@ -56,40 +59,41 @@ var FolderPaneController =
return false;
case "cmd_delete":
case "button_delete":
if ( command == "cmd_delete" )
goSetMenuValue(command, 'valueFolder');
var folderTree = GetFolderTree();
var startIndex = {};
var endIndex = {};
folderTree.treeBoxObject.selection.getRangeAt(0, startIndex, endIndex);
if (startIndex.value >= 0) {
var canDeleteThisFolder;
var specialFolder = null;
var isServer = null;
var serverType = null;
try {
var folderResource = GetFolderResource(folderTree, startIndex.value);
specialFolder = GetFolderAttribute(folderTree, folderResource, "SpecialFolder");
isServer = GetFolderAttribute(folderTree, folderResource, "IsServer");
serverType = GetFolderAttribute(folderTree, folderResource, "ServerType");
if (serverType == "nntp") {
if ( command == "cmd_delete" ) {
goSetMenuValue(command, 'valueNewsgroup');
goSetAccessKey(command, 'valueNewsgroupAccessKey');
}
}
}
catch (ex) {
//dump("specialFolder failure: " + ex + "\n");
}
if (specialFolder == "Inbox" || specialFolder == "Trash" || isServer == "true")
canDeleteThisFolder = false;
else
canDeleteThisFolder = true;
return canDeleteThisFolder && isCommandEnabled(command);
}
else
return false;
if ( command == "cmd_delete" )
goSetMenuValue(command, 'valueFolder');
var folderTree = GetFolderTree();
var startIndex = {};
var endIndex = {};
folderTree.treeBoxObject.selection.getRangeAt(0, startIndex, endIndex);
if (startIndex.value >= 0) {
var canDeleteThisFolder;
var specialFolder = null;
var isServer = null;
var serverType = null;
try {
var folderResource = GetFolderResource(folderTree, startIndex.value);
specialFolder = GetFolderAttribute(folderTree, folderResource, "SpecialFolder");
isServer = GetFolderAttribute(folderTree, folderResource, "IsServer");
serverType = GetFolderAttribute(folderTree, folderResource, "ServerType");
if (serverType == "nntp") {
if ( command == "cmd_delete" ) {
goSetMenuValue(command, 'valueNewsgroup');
goSetAccessKey(command, 'valueNewsgroupAccessKey');
}
}
}
catch (ex) {
//dump("specialFolder failure: " + ex + "\n");
}
if (specialFolder == "Inbox" || specialFolder == "Trash" || isServer == "true")
canDeleteThisFolder = false;
else
canDeleteThisFolder = true;
return canDeleteThisFolder && isCommandEnabled(command);
}
else
return false;
default:
return false;
}
@ -281,7 +285,10 @@ var DefaultController =
var enabled = new Object();
enabled.value = false;
var checkStatus = new Object();
if (IsFakeAccount())
return false;
// note, all commands that get fired on a single key need to check MailAreaHasFocus() as well
switch ( command )
{
@ -1083,3 +1090,14 @@ function isCommandEnabled(cmd)
}
function IsFakeAccount() {
try {
var folderResource = GetSelectedFolderResource();
return (folderResource.Value == "http://home.netscape.com/NC-rdf#PageTitleFakeAccount");
}
catch(ex) {
}
return false;
}

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

@ -220,6 +220,9 @@ function folderPaneOnPopupHiding()
function fillFolderPaneContextMenu()
{
if (IsFakeAccount())
return false;
var folderTree = GetFolderTree();
var startIndex = {};
var endIndex = {};

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

@ -60,6 +60,7 @@ var messagesBox = null;
var accountCentralBox = null;
var gSearchBox = null;
var gAccountCentralLoaded = false;
var gFakeAccountPageLoaded = false;
var gPaneConfig = null;
//End progress and Status variables
@ -510,6 +511,7 @@ function HideAccountCentral()
switch (gPaneConfig)
{
case 0:
window.frames["accountCentralPane"].location = "about:blank";
accountCentralBox.setAttribute("collapsed", "true");
gSearchBox.removeAttribute("collapsed");
messagesBox.removeAttribute("collapsed");
@ -517,6 +519,7 @@ function HideAccountCentral()
break;
case 1:
window.frames["accountCentralPane"].location = "about:blank";
accountCentralBox.setAttribute("collapsed", "true");
var messagePaneBox = document.getElementById("messagepanebox");
messagePaneBox.removeAttribute("collapsed");

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

@ -391,10 +391,7 @@ Rights Reserved.
datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
ref="msgaccounts:/">
<template>
<rule nc:CanSearchMessages="false">
<!-- don't show servers (nntp & any others) which do not allow searching -->
</rule>
<rule iscontainer="true" isempty="false">
<rule iscontainer="true" isempty="false" nc:CanSearchMessages="true">
<menupopup>
<menu uri="..."
class="folderMenuItem menu-iconic"
@ -413,7 +410,7 @@ Rights Reserved.
</menu>
</menupopup>
</rule>
<rule>
<rule nc:CanSearchMessages="true">
<menupopup>
<menuitem uri="..." value="..."
class="folderMenuItem menuitem-iconic"

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

@ -68,7 +68,6 @@ var gHaveLoadedMessage;
var gDisplayStartupPage = false;
// the folderListener object
var folderListener = {
OnItemAdded: function(parentItem, item, view) { },
@ -1053,9 +1052,13 @@ function GetSelectedMsgFolders()
folderTree.treeBoxObject.selection.getRangeAt(i, startIndex, endIndex);
for (var j = startIndex.value; j <= endIndex.value; j++)
{
var msgFolder = GetFolderResource(folderTree, j).QueryInterface(Components.interfaces.nsIMsgFolder);
var folderResource = GetFolderResource(folderTree, j);
if (folderResource.Value != "http://home.netscape.com/NC-rdf#PageTitleFakeAccount") {
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
if(msgFolder)
folderArray[k++] = msgFolder;
folderArray[k++] = msgFolder;
}
}
}

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

@ -59,6 +59,7 @@
#include "nsICategoryManager.h"
#include "nsISupportsPrimitives.h"
#include "nsIPrefService.h"
// turn this on to see useful output
#undef DEBUG_amds
@ -72,6 +73,7 @@
#define NC_RDF_PAGETITLE_DISKSPACE NC_RDF_PAGETITLE_PREFIX "DiskSpace"
#define NC_RDF_PAGETITLE_ADDRESSING NC_RDF_PAGETITLE_PREFIX "Addressing"
#define NC_RDF_PAGETITLE_SMTP NC_RDF_PAGETITLE_PREFIX "SMTP"
#define NC_RDF_PAGETITLE_FAKEACCOUNT NC_RDF_PAGETITLE_PREFIX "FakeAccount"
#define NC_RDF_PAGETAG NC_NAMESPACE_URI "PageTag"
@ -120,6 +122,7 @@ nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleDiskSpace=nsnull;
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleAddressing=nsnull;
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleAdvanced=nsnull;
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleSMTP=nsnull;
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleFakeAccount=nsnull;
// common literals
nsIRDFLiteral* nsMsgAccountManagerDataSource::kTrueLiteral = nsnull;
@ -171,6 +174,7 @@ nsMsgAccountManagerDataSource::nsMsgAccountManagerDataSource()
getRDFService()->GetResource(NC_RDF_PAGETITLE_ADDRESSING, &kNC_PageTitleAddressing);
getRDFService()->GetResource(NC_RDF_PAGETITLE_ADVANCED, &kNC_PageTitleAdvanced);
getRDFService()->GetResource(NC_RDF_PAGETITLE_SMTP, &kNC_PageTitleSMTP);
getRDFService()->GetResource(NC_RDF_PAGETITLE_FAKEACCOUNT, &kNC_PageTitleFakeAccount);
getRDFService()->GetResource(NC_RDF_ACCOUNTROOT, &kNC_AccountRoot);
@ -214,6 +218,7 @@ nsMsgAccountManagerDataSource::~nsMsgAccountManagerDataSource()
NS_IF_RELEASE(kNC_PageTitleAddressing);
NS_IF_RELEASE(kNC_PageTitleAdvanced);
NS_IF_RELEASE(kNC_PageTitleSMTP);
NS_IF_RELEASE(kNC_PageTitleFakeAccount);
NS_IF_RELEASE(kTrueLiteral);
NS_IF_RELEASE(kNC_AccountRoot);
@ -284,8 +289,8 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source,
nsIRDFNode **target)
{
nsresult rv;
rv = NS_RDF_NO_VALUE;
nsAutoString str;
@ -320,6 +325,24 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source,
mStringBundle->GetStringFromName(NS_LITERAL_STRING("prefPanel-smtp").get(),
getter_Copies(pageTitle));
else if (source == kNC_PageTitleFakeAccount) {
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
if (NS_SUCCEEDED(rv))
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
PRBool showFakeAccount;
rv = prefBranch->GetBoolPref("mailnews.fakeaccount.show", &showFakeAccount);
if (showFakeAccount) {
nsCOMPtr<nsIStringBundleService> strBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = strBundleService->CreateBundle("chrome://messenger/locale/fakeAccount.properties",
getter_AddRefs(mStringBundle));
if (NS_SUCCEEDED(rv))
mStringBundle->GetStringFromName(NS_LITERAL_STRING("prefPanel-fake-account").get(),
getter_Copies(pageTitle));
}
}
else {
// if it's a server, use the pretty name
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(source, &rv);
@ -499,6 +522,10 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source,
if (canGetMessages(server))
str = NS_LITERAL_STRING("true");
}
else if (property == kNC_PageTitleFakeAccount) {
if (source == kNC_PageTitleFakeAccount)
str = NS_LITERAL_STRING("true");
}
if (!str.IsEmpty())
rv = createNode(str.get(), target, getRDFService());
@ -582,6 +609,9 @@ nsMsgAccountManagerDataSource::createRootResources(nsIRDFResource *property,
// for the "settings" arc, we also want to do an SMTP tag
if (property == kNC_Settings) {
aNodeArray->AppendElement(kNC_PageTitleSMTP);
}
else if (property == kNC_Child && IsFakeAccountRequired()) {
aNodeArray->AppendElement(kNC_PageTitleFakeAccount);
}
}
@ -1140,6 +1170,13 @@ nsMsgAccountManagerDataSource::OnServerLoaded(nsIMsgIncomingServer* aServer)
NotifyObservers(kNC_AccountRoot, kNC_Child, serverResource, PR_TRUE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, serverResource, PR_TRUE, PR_FALSE);
PRBool fakeAccountServer;
IsIncomingServerForFakeAccount(aServer, &fakeAccountServer);
if (fakeAccountServer)
NotifyObservers(kNC_AccountRoot, kNC_Child, kNC_PageTitleFakeAccount, PR_FALSE, PR_FALSE);
return NS_OK;
}
@ -1148,7 +1185,6 @@ nsMsgAccountManagerDataSource::OnServerUnloaded(nsIMsgIncomingServer* aServer)
{
nsresult rv;
nsCOMPtr<nsIFolder> serverFolder;
rv = aServer->GetRootFolder(getter_AddRefs(serverFolder));
if (NS_FAILED(rv)) return rv;
@ -1160,6 +1196,7 @@ nsMsgAccountManagerDataSource::OnServerUnloaded(nsIMsgIncomingServer* aServer)
NotifyObservers(kNC_AccountRoot, kNC_Child, serverResource, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, serverResource, PR_FALSE, PR_FALSE);
return NS_OK;
}
@ -1242,3 +1279,75 @@ nsMsgAccountManagerDataSource::OnItemIntPropertyChanged(nsISupports *, nsIAtom *
return NS_OK;
}
PRBool
nsMsgAccountManagerDataSource::IsFakeAccountRequired()
{
nsresult rv;
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
if (NS_SUCCEEDED(rv))
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
PRBool showFakeAccount;
rv = prefBranch->GetBoolPref("mailnews.fakeaccount.show", &showFakeAccount);
if (!showFakeAccount)
return PR_FALSE;
nsXPIDLCString fakeHostName;
rv = GetFakeAccountHostName(getter_Copies(fakeHostName));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIMsgAccountManager> accountManager = do_QueryReferent(mAccountManager);
if (!accountManager)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIMsgIncomingServer> server;
if (!fakeHostName.IsEmpty()) {
rv = accountManager->FindServer("",fakeHostName.get(),"", getter_AddRefs(server));
if (NS_SUCCEEDED(rv) && server)
return PR_FALSE;
}
return PR_TRUE;
}
nsresult
nsMsgAccountManagerDataSource::IsIncomingServerForFakeAccount(nsIMsgIncomingServer* aServer, PRBool *aResult)
{
NS_ENSURE_ARG_POINTER(aServer);
NS_ENSURE_ARG_POINTER(aResult);
nsresult rv;
nsXPIDLCString fakeAccountHostName;
rv = GetFakeAccountHostName(getter_Copies(fakeAccountHostName));
NS_ENSURE_SUCCESS(rv,rv);
if (fakeAccountHostName.IsEmpty()) {
*aResult = PR_FALSE;
return NS_OK;
}
nsXPIDLCString hostname;
rv = aServer->GetHostName(getter_Copies(hostname));
NS_ENSURE_SUCCESS(rv,rv);
*aResult = (strcmp(hostname.get(), fakeAccountHostName) == 0);
return NS_OK;
}
nsresult
nsMsgAccountManagerDataSource::GetFakeAccountHostName(char **aHostName)
{
NS_ENSURE_ARG_POINTER(aHostName);
nsresult rv;
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
if (NS_SUCCEEDED(rv))
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
rv = prefBranch->GetCharPref("mailnews.fakeaccount.server", aHostName);
return NS_OK;
}

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

@ -122,6 +122,10 @@ protected:
nsresult appendGenericSettingsResources(nsIMsgIncomingServer *server, nsISupportsArray *aNodeArray);
nsresult appendGenericSetting(const char *name, nsISupportsArray *aNodeArray);
PRBool IsFakeAccountRequired();
nsresult GetFakeAccountHostName(char **aHostName);
nsresult IsIncomingServerForFakeAccount(nsIMsgIncomingServer* aServer, PRBool *aResult);
static nsIRDFResource* kNC_Name;
static nsIRDFResource* kNC_FolderTreeName;
static nsIRDFResource* kNC_FolderTreeSimpleName;
@ -148,6 +152,7 @@ protected:
static nsIRDFResource* kNC_PageTitleAddressing;
static nsIRDFResource* kNC_PageTitleAdvanced;
static nsIRDFResource* kNC_PageTitleSMTP;
static nsIRDFResource* kNC_PageTitleFakeAccount;
static nsIRDFLiteral* kTrueLiteral;

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

@ -407,4 +407,8 @@ pref("mailnews.labels.color.5", "#993399"); // default: purple
//default null headers
//example "X-Warn: XReply", list of hdrs separated by ": "
pref("mailnews.customHeaders", "");
pref("mailnews.fakeaccount.show", false);
pref("mailnews.fakeaccount.server", "");

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

@ -407,4 +407,8 @@ pref("mailnews.labels.color.5", "#993399"); // default: purple
//default null headers
//example "X-Warn: XReply", list of hdrs separated by ": "
pref("mailnews.customHeaders", "");
pref("mailnews.fakeaccount.show", false);
pref("mailnews.fakeaccount.server", "");