add UI for global pop3 inbox in account wizard and account settings, r=mscott, sr=sspitzer, 243837

git-svn-id: svn://10.0.0.236/trunk@157709 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bienvenu%nventure.com 2004-06-10 14:04:32 +00:00
parent ee4c147c9c
commit e7755520ae
23 changed files with 435 additions and 64 deletions

View File

@ -208,6 +208,10 @@ function FinishAccount()
accountData.smtpRequiresUsername = true;
}
// we may need local folders before account is "Finished"
// if it's a pop3 account which defers to Local Folders.
verifyLocalFoldersAccount(gCurrentAccount);
PageDataToAccountData(pageData, accountData);
FixupAccountDataForIsp(accountData);
@ -219,8 +223,6 @@ function FinishAccount()
// transfer all attributes from the accountdata
finishAccount(gCurrentAccount, accountData);
verifyLocalFoldersAccount(gCurrentAccount);
if (!serverIsNntp(pageData))
EnableCheckMailAtStartUpIfNeeded(gCurrentAccount);
@ -335,6 +337,8 @@ function PageDataToAccountData(pageData, accountData)
accountData.incomingServer = new Object;
if (!accountData.smtp)
accountData.smtp = new Object;
if (!accountData.pop3)
accountData.pop3 = new Object;
var identity = accountData.identity;
var server = accountData.incomingServer;
@ -346,7 +350,19 @@ function PageDataToAccountData(pageData, accountData)
server.type = getCurrentServerType(pageData);
server.hostName = getCurrentHostname(pageData);
if (getCurrentServerIsDeferred(pageData))
{
try
{
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
var localFoldersServer = accountManager.localFoldersServer;
var localFoldersAccount = accountManager.FindAccountForServer(localFoldersServer);
accountData.pop3.deferredToAccount = localFoldersAccount.key;
accountData.pop3.deferGetNewMail = true;
server["ServerType-pop3"] = accountData.pop3;
}
catch (ex) {dump ("exception setting up deferred account" + ex);}
}
if (serverIsNntp(pageData)) {
// this stuff probably not relevant
dump("not setting username/password/rememberpassword/etc\n");
@ -409,7 +425,12 @@ function createAccount(accountData)
dump("am.createAccount()\n");
var account = am.createAccount();
account.addIdentity(identity);
// we mark the server as invalid so that the account manager won't
// tell RDF about the new server - it's not quite finished getting
// set up yet, in particular, the deferred storage pref hasn't been set.
server.valid = false;
account.incomingServer = server;
server.valid = true;
return account;
}
@ -440,6 +461,8 @@ function finishAccount(account, accountData)
}
}
account.incomingServer.valid=true;
// hack to cause an account loaded notification now the server is valid
account.incomingServer = account.incomingServer;
}
// copy identity info
@ -556,16 +579,11 @@ function verifyLocalFoldersAccount(account)
}
try {
var server = account.incomingServer;
var identity = account.identities.QueryElementAt(0, Components.interfaces.nsIMsgIdentity);
// for this server, do we default the folder prefs to this server, or to the "Local Folders" server
var defaultCopiesAndFoldersPrefsToServer = server.defaultCopiesAndFoldersPrefsToServer;
if (!localMailServer) {
// dump("Creating local mail account\n");
// creates a copy of the identity you pass in
messengerMigrator = Components.classes["@mozilla.org/messenger/migrator;1"].getService(Components.interfaces.nsIMessengerMigrator);
messengerMigrator = Components.classes["@mozilla.org/messenger/migrator;1"].getService(Components.interfaces.nsIMessengerMigrator);
messengerMigrator.createLocalMailAccount(false /* false, since we are not migrating */);
try {
localMailServer = am.localFoldersServer;
@ -576,6 +594,11 @@ function verifyLocalFoldersAccount(account)
}
}
var server = account.incomingServer;
var identity = account.identities.QueryElementAt(0, Components.interfaces.nsIMsgIdentity);
// for this server, do we default the folder prefs to this server, or to the "Local Folders" server
var defaultCopiesAndFoldersPrefsToServer = server.defaultCopiesAndFoldersPrefsToServer;
var copiesAndFoldersServer = null;
if (defaultCopiesAndFoldersPrefsToServer) {
copiesAndFoldersServer = server;
@ -840,6 +863,13 @@ function getCurrentServerType(pageData) {
return servertype;
}
function getCurrentServerIsDeferred(pageData) {
var serverDeferred = false;
if (pageData.server && pageData.server.deferStorage)
serverDeferred = true;
return serverDeferred;
}
function getCurrentHostname(pageData) {
if (serverIsNntp(pageData))
return pageData.newsserver.hostname.value;

View File

@ -160,6 +160,14 @@
accesskey="&incomingServerLabel.accesskey;" control="incomingServer"/>
<textbox wsm_persist="true" id="incomingServer" flex="1" class="uri-element"/>
</hbox>
</vbox>
<separator class="groove"/>
<vbox id="deferStorageBox">
<description> &deferStorageDesc.label;</description>
<hbox>
<checkbox id="deferStorage" label="&deferStorage.label;" checked="true"
wsm_persist="true" oncommand="setDeferStorage();"/>
</hbox>
<separator/>
</vbox>

View File

@ -21,6 +21,7 @@
*
* Contributor(s):
* Alec Flett <alecf@netscape.com>
* David Bienvenu <bienvenu@nventure.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -37,11 +38,13 @@
* ***** END LICENSE BLOCK ***** */
// pull stuff out of window.arguments
var server = window.arguments[0];
var gServerSettings = window.arguments[0];
var serverList;
// initialize the controls with the "server" argument
var gAccountManager;
var gFirstDeferredAccount;
// initialize the controls with the "gServerSettings" argument
var gControls;
function getControls()
@ -51,45 +54,149 @@ function getControls()
return gControls;
}
function getLocalFoldersAccount()
{
var localFoldersServer = gAccountManager.localFoldersServer;
return gAccountManager.FindAccountForServer(localFoldersServer);
}
function onLoad()
{
if (server.serverType == "imap")
if (gServerSettings.serverType == "imap")
{
document.getElementById("tabbox").selectedTab = document.getElementById("imapTab");
document.getElementById("pop3Tab").hidden = true;
// don't hide panel - it hides all subsequent panels
}
else if (gServerSettings.serverType == "pop3")
{
var radioGroup = document.getElementById("folderStorage");
document.getElementById("tabbox").selectedTab = document.getElementById("pop3Tab");
document.getElementById("imapTab").hidden = true;
// just hide the tab, don't hide panel - it hides all subsequent panels
gAccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
gFirstDeferredAccount = gServerSettings.deferredToAccount;
var localFoldersAccount = getLocalFoldersAccount();
if (gFirstDeferredAccount.length)
{
var account = gAccountManager.getAccount(gFirstDeferredAccount);
if (account)
{
var thisServer = account.incomingServer;
SetFolderPicker(thisServer.serverURI, 'deferedServerFolderPicker');
}
if (gFirstDeferredAccount == localFoldersAccount.key)
{
radioGroup.selectedItem = document.getElementById("globalInbox");
SetFolderPicker(localFoldersAccount.incomingServer.serverURI, 'deferedServerFolderPicker');
updateInboxAccount(false, true);
}
else
{
radioGroup.selectedItem = document.getElementById("deferToServer");
SetFolderPicker(account.incomingServer.serverURI, 'deferedServerFolderPicker');
updateInboxAccount(true, true);
}
}
else
{
radioGroup.selectedItem = document.getElementById("accountDirectory");
// we should find out if there's another pop3/movemail server to defer to,
// perhaps by checking the number of elements in the picker. For now,
// just use the local folders account
SetFolderPicker(localFoldersAccount.incomingServer.serverURI, 'deferedServerFolderPicker');
updateInboxAccount(false, false);
}
}
else
{
document.getElementById("imapTab").hidden = true;
document.getElementById("imapTabPanel").hidden = true;
document.getElementById("pop3Tab").hidden = true;
}
var controls = getControls();
for (var i = 0; i < controls.length; i++)
{
var slot = controls[i].id;
if (slot in server)
if (slot in gServerSettings)
{
if (controls[i].localName == "checkbox")
controls[i].checked = server[slot];
controls[i].checked = gServerSettings[slot];
else
controls[i].value = server[slot];
controls[i].value = gServerSettings[slot];
}
}
}
// save the controls back to the "server" array
// save the controls back to the "gServerSettings" array
function onOk()
{
var controls = getControls();
radioGroup = document.getElementById("folderStorage");
gPrefsBundle = document.getElementById("bundle_prefs");
// if this account wasn't deferred, and is now...
if (radioGroup.value != 1 && !gFirstDeferredAccount.length)
{
var confirmDeferAccount =
gPrefsBundle.getString("confirmDeferAccount");
var confirmTitle = gPrefsBundle.getString("confirmDeferAccountTitle");
var promptService =
Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
getService(Components.interfaces.nsIPromptService);
if (!promptService ||
!promptService.confirm(window, confirmTitle, confirmDeferAccount))
return;
}
switch (radioGroup.value)
{
case "0":
gServerSettings['deferredToAccount'] = getLocalFoldersAccount().key;
break;
case "1":
gServerSettings['deferredToAccount'] = "";
break;
case "2":
picker = document.getElementById("deferedServerFolderPicker");
var server = GetMsgFolderFromUri(picker.getAttribute("uri"), false).server;
var account = gAccountManager.FindAccountForServer(server);
gServerSettings['deferredToAccount'] = account.key;
break;
}
for (var i = 0; i < controls.length; i++)
{
var slot = controls[i].id;
if (slot in server)
if (slot in gServerSettings)
{
if (controls[i].localName == "checkbox")
server[slot] = controls[i].checked;
gServerSettings[slot] = controls[i].checked;
else
server[slot] = controls[i].value;
gServerSettings[slot] = controls[i].value;
}
}
}
// Set radio element choices and picker states
function updateInboxAccount(showPicker, showDeferGetNewMail, event)
{
var picker = document.getElementById('deferedServerFolderPicker');
if (showPicker)
{
picker.hidden = false;
picker.removeAttribute("disabled");
}
else
{
picker.hidden = true;
}
var deferCheckbox = document.getElementById('deferGetNewMail');
deferCheckbox.hidden = !showDeferGetNewMail;
}

View File

@ -39,6 +39,8 @@
<?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
<?xul-overlay href="chrome://messenger/content/msgFolderPickerOverlay.xul"?>
<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/am-server-advanced.dtd">
<dialog
@ -49,11 +51,13 @@
ondialogaccept="return onOk();">
<script type="application/x-javascript" src="am-server-advanced.js"/>
<stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"/>
<tabbox id="tabbox" flex="1">
<tabs id="tabs">
<tab id="smtpTab" label="SMTP"/>
<tab id="imapTab" label="IMAP"/>
<tab id="pop3Tab" label="POP"/>
</tabs>
<tabpanels id="tabpanels" flex="1">
@ -161,6 +165,38 @@
</rows>
</grid>
</vbox>
<!-- POP3 Tab -->
<vbox id="pop3TabPanel">
<description style="width: 20em; ">&pop3Desc.label;</description>
<separator class="thin"/>
<hbox align="center">
<radiogroup id="folderStorage"
orient="horizontal" amsa_persist="true">
<rows>
<row align = "center">
<radio value="0" id = "globalInbox" label="&globalInbox.label;"
oncommand="updateInboxAccount(false, true)"
accesskey="&globalInbox.accesskey;"/>
</row>
<row>
<radio value="1" id = "accountDirectory" label="&accountDirectory.label;"
accesskey="&accountDirectory.accesskey;"
oncommand="updateInboxAccount(false, false)" />
</row>
<row>
<radio value="2" id = "deferToServer" label="&deferToServer.label;"
accesskey="&deferToServer.accesskey;"
oncommand="updateInboxAccount(true, true)"
/>
<menulist id="deferedServerFolderPicker" />
</row>
</rows>
</radiogroup>
</hbox>
<checkbox amsa_persist="true" id="deferGetNewMail"
label="&deferGetNewMail.label;"
accesskey="&deferGetNewMail.accesskey;"/>
</vbox>
</tabpanels>
</tabbox>
</dialog>

View File

@ -42,6 +42,7 @@
* ***** END LICENSE BLOCK ***** */
var gRedirectorType = "";
var gServer;
function onInit()
{
@ -63,6 +64,7 @@ function onPreInit(account, accountValues)
gRedirectorType = parent.getAccountValue(account, accountValues, "server", "redirectorType", null, false);
hideShowControls(type);
gServer = account.incomingServer;
if(!(account.incomingServer.isSecureServer))
document.getElementById("server.isSecure").setAttribute("hidden", "true");
else
@ -120,14 +122,14 @@ function onAdvanced()
var serverSettings = {};
serverSettings.smtpServerList = oldSmtpServerKey;
// Store the server type and, if an IMAP server,
// the settings needed for the IMAP tab into the array
// Store the server type and, if an IMAP or POP3 server,
// the settings needed for the IMAP/POP3 tab into the array
var serverType = document.getElementById("server.type").getAttribute("value");
serverSettings.serverType = serverType;
if (serverType == "imap")
{
serverSettings.dualUseFolders = document.getElementById("imap.dualUseFolders").checked
serverSettings.dualUseFolders = document.getElementById("imap.dualUseFolders").checked;
serverSettings.usingSubscription = document.getElementById("imap.usingSubscription").checked;
serverSettings.useIdle = document.getElementById("imap.useIdle").checked;
serverSettings.maximumConnectionsNumber = document.getElementById("imap.maximumConnectionsNumber").getAttribute("value");
@ -138,8 +140,12 @@ function onAdvanced()
serverSettings.otherUsersNamespace = document.getElementById("imap.otherUsersNamespace").getAttribute("value");
serverSettings.overrideNamespaces = document.getElementById("imap.overrideNamespaces").checked;
}
else if (serverType == "pop3")
{
serverSettings.deferGetNewMail = document.getElementById("pop3.deferGetNewMail").checked;
serverSettings.deferredToAccount = document.getElementById("pop3.deferredToAccount").getAttribute("value");
}
dump("Opening dialog..\n");
window.openDialog("chrome://messenger/content/am-server-advanced.xul",
"_blank", "chrome,modal,titlebar", serverSettings);
@ -165,6 +171,14 @@ function onAdvanced()
document.getElementById("imap.otherUsersNamespace").setAttribute("value", serverSettings.otherUsersNamespace);
document.getElementById("imap.overrideNamespaces").checked = serverSettings.overrideNamespaces;
}
else if (serverType == "pop3")
{
document.getElementById("pop3.deferGetNewMail").checked = serverSettings.deferGetNewMail;
document.getElementById("pop3.deferredToAccount").setAttribute("value", serverSettings.deferredToAccount);
var pop3Server = gServer.QueryInterface(Components.interfaces.nsIPop3IncomingServer);
// we're explicitly setting this so we'll go through the SetDeferredToAccount method
pop3Server.deferredToAccount = serverSettings.deferredToAccount;
}
}
function secureSelect() {

View File

@ -173,6 +173,17 @@
accesskey="&deleteOnServer.accesskey;"
prefattribute="value"
prefstring="mail.server.%serverkey%.delete_mail_left_on_server"/>
<!-- hidden elements for data transfer to and from advanced... dialog -->
<hbox flex="1" hidefor="imap,nntp,movemail" hidden="true">
<checkbox hidden="true" wsm_persist="true" id="pop3.deferGetNewMail"
prefattribute="value"
prefstring="mail.server.%serverkey%.deferGetNewMail"/>
<label hidden="true" wsm_persist="true" id="pop3.deferredToAccount"
prefattribute="value"
prefstring="mail.server.%serverkey%.deferredToAccount"/>
</hbox>
</vbox>
<!-- IMAP -->
<hbox align="center" id="imap.deleteModel.box" hidefor="pop3,nntp,movemail">

View File

@ -147,6 +147,7 @@ function serverPageInit() {
serverTypeRadioGroup.selectedItem = pop3RadioItem;
}
setServerType();
setDeferStorage(); // set the initial value correctly
}
gPrefsBundle = document.getElementById("bundle_prefs");
@ -201,5 +202,16 @@ function setServerType()
{
var pageData = parent.GetPageData();
var serverType = (document.getElementById("servertype")).selectedItem.value;
var deferStorageBox = document.getElementById("deferStorageBox");
deferStorageBox.hidden = serverType == "imap";
setPageData(pageData, "server", "servertype", serverType);
}
function setDeferStorage()
{
var pageData = parent.GetPageData();
var deferStorage = (document.getElementById("deferStorage")).checked;
setPageData(pageData, "server", "deferStorage", deferStorage);
}

View File

@ -1,7 +1,7 @@
<!-- Entities for AccountWizard -->
<!ENTITY windowTitle.label "Account Wizard">
<!ENTITY accountWizard.size "width: 40em; height: 30em;">
<!ENTITY accountWizard.size "width: 40em; height: 38em;">
<!-- Entities for Account Type page -->
@ -117,4 +117,6 @@
<!ENTITY smtpServerNamePrefix.label "Outgoing Server Name (SMTP):">
<!ENTITY newsServerNamePrefix.label "News Server Name (NNTP):">
<!ENTITY downloadOnLogin.label "Download messages now">
<!ENTITY deferStorageDesc.label "Uncheck this checkbox to store mail for this account in its own directory. That will make this account appear as a top-level account. Otherwise, it will be part of the Local Folders Global Inbox account.">
<!ENTITY deferStorage.label "Use Global Inbox (store mail in Local Folders)">
<!ENTITY clickFinish.label "Click Finish to save these settings and exit the Account Wizard.">

View File

@ -26,3 +26,13 @@
<!ENTITY otherUsersNamespace.accesskey "O">
<!ENTITY overrideNamespaces.label "Allow server to override these namespaces">
<!ENTITY overrideNamespaces.accesskey "A">
<!ENTITY pop3Desc.label "When downloading pop3 mail for this server, you can store it in the Global Inbox (the INBOX in the Local Folders Account), in the INBOX for this account, or in the INBOX for another POP3 account" >
<!ENTITY folderStorage.label "Where to store mail">
<!ENTITY globalInbox.label "Global Inbox (Local Folders Account)">
<!ENTITY globalInbox.accesskey "G">
<!ENTITY accountDirectory.label "Inbox for this server's account">
<!ENTITY accountDirectory.accesskey "S">
<!ENTITY deferToServer.label "Inbox for different account">
<!ENTITY deferToServer.accesskey "D">
<!ENTITY deferGetNewMail.label "Include this server when getting new mail">
<!ENTITY deferGetNewMail.accesskey "I">

View File

@ -65,6 +65,9 @@ confirmRemoveAccountTitle=Remove Account
#LOCALIZATION NOTE: accountName: %1$S is server name, %2$S is user name
accountName=%1$S - %2$S
confirmDeferAccount=If you store this account's new mail in a different account's Inbox, you will no longer be able to access already downloaded e-mail for this account. If you have mail in this account, please copy it to another account first. If you have filters that filter mail into this account, you should disable them or change the destination folder. If any accounts have special folders in this account (Sent, Drafts, Templates), you should change them to be in another account. Do you still want to store this account's e-mail in a different account?
confirmDeferAccountTitle=Defer Account?
#Provide default example values for sample email address
exampleEmailUserName=user
exampleEmailDomain=example.net

View File

@ -59,7 +59,7 @@
<rule>
<conditions>
<content uri="?container"/>
<member container="?container" child="?member" />
<member container="?container" child="?member" isDeferred="?isDeferred" />
<triple subject="?member" predicate="http://home.netscape.com/NC-rdf#IsDeferred" object="false"/>
</conditions>
@ -118,6 +118,9 @@
<binding subject="?member"
predicate="http://home.netscape.com/NC-rdf#PageTitleFakeAccount"
object="?fakeAccount" />
<binding subject="?member"
predicate="http://home.netscape.com/NC-rdf#IsDeferred"
object="?isDeferred" />
</bindings>
<action>

View File

@ -588,4 +588,29 @@
</template>
<menupopup/>
</menulist>
<menulist label="&chooseserverToDeferTo.label;" uri="" id="deferedServerFolderPicker"
sortResource="http://home.netscape.com/NC-rdf#FolderTreeName"
sortDirection="ascending"
datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
ref="msgaccounts:/">
<template>
<!-- Using CanCreateFoldersOnServer+SupportsOffline is a hack that allows
us to remove news and imap accounts. We should be using our own
attribute, canDeferTo, but I want to make the folder data source
table driven before I add code to it.
-->
<rule nc:IsServer="true" nc:CanCreateFoldersOnServer="true" nc:SupportsOffline="false">
<menupopup>
<menuitem uri="..." class="folderMenuItem menuitem-iconic"
label="rdf:http://home.netscape.com/NC-rdf#Name"
oncommand="PickedMsgFolder(event.target,'deferedServerFolderPicker')"
IsServer="rdf:http://home.netscape.com/NC-rdf#IsServer"
IsSecure="rdf:http://home.netscape.com/NC-rdf#IsSecure"
ServerType="rdf:http://home.netscape.com/NC-rdf#ServerType"
CanCreateFoldersOnServer="rdf:http://home.netscape.com/NC-rdf#CanCreateFoldersOnServer"/>
</menupopup>
</rule>
</template>
<menupopup />
</menulist>
</overlay>

View File

@ -46,3 +46,4 @@
<!ENTITY filemessagesclickhere.label "click here to choose a folder">
<!ENTITY chooseaccountclickhere.label "Click here to select an account">
<!ENTITY choosefolderclickhere.label "Click here to select a folder">
<!ENTITY chooseserverToDeferTo.label "click here to select an account to use for storing messages">

View File

@ -185,9 +185,15 @@ nsMsgAccount::SetIncomingServer(nsIMsgIncomingServer * aIncomingServer)
m_incomingServer = aIncomingServer;
PRBool serverValid;
(void) aIncomingServer->GetValid(&serverValid);
// only notify server loaded if server is valid so
// account manager only gets told about finished accounts.
if (serverValid)
{
nsCOMPtr<nsIMsgAccountManager> accountManager =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(rv))
accountManager->NotifyServerLoaded(aIncomingServer);
}
return NS_OK;

View File

@ -1252,15 +1252,15 @@ nsMsgAccountManagerDataSource::OnServerLoaded(nsIMsgIncomingServer* aServer)
printf("nsMsgAccountmanagerDataSource::OnServerLoaded(%s)\n", (const char*)serverUri);
#endif
NotifyObservers(kNC_AccountRoot, kNC_Child, serverResource, PR_TRUE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, serverResource, PR_TRUE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Child, serverResource, nsnull, PR_TRUE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, serverResource, nsnull, PR_TRUE, PR_FALSE);
PRBool fakeAccountServer;
IsIncomingServerForFakeAccount(aServer, &fakeAccountServer);
if (fakeAccountServer) {
NotifyObservers(kNC_AccountRoot, kNC_Child, kNC_PageTitleFakeAccount, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, kNC_PageTitleFakeAccount, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Child, kNC_PageTitleFakeAccount, nsnull, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, kNC_PageTitleFakeAccount, nsnull, PR_FALSE, PR_FALSE);
}
return NS_OK;
@ -1277,8 +1277,8 @@ nsMsgAccountManagerDataSource::OnServerUnloaded(nsIMsgIncomingServer* aServer)
if (NS_FAILED(rv)) return rv;
NotifyObservers(kNC_AccountRoot, kNC_Child, serverResource, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, serverResource, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Child, serverResource, nsnull, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, serverResource, nsnull, PR_FALSE, PR_FALSE);
return NS_OK;
}
@ -1327,7 +1327,7 @@ nsMsgAccountManagerDataSource::OnItemBoolPropertyChanged(nsIRDFResource *aItem,
PRBool aNewValue)
{
if (aProperty == kDefaultServerAtom)
NotifyObservers(aItem, kNC_IsDefaultServer, kTrueLiteral, aNewValue, PR_FALSE);
NotifyObservers(aItem, kNC_IsDefaultServer, kTrueLiteral, nsnull, aNewValue, PR_FALSE);
return NS_OK;
}
@ -1425,8 +1425,8 @@ nsMsgAccountManagerDataSource::Observe(nsISupports *aSubject, const char *aTopic
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
nsDependentString prefName(aData);
if (prefName.EqualsLiteral(PREF_SHOW_FAKE_ACCOUNT)) {
NotifyObservers(kNC_AccountRoot, kNC_Child, kNC_PageTitleFakeAccount, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, kNC_PageTitleFakeAccount, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Child, kNC_PageTitleFakeAccount, nsnull, PR_FALSE, PR_FALSE);
NotifyObservers(kNC_AccountRoot, kNC_Settings, kNC_PageTitleFakeAccount, nsnull, PR_FALSE, PR_FALSE);
}
}
else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {

View File

@ -127,6 +127,8 @@ nsIAtom * nsMsgFolderDataSource::kFolderSizeAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kNameAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kSynchronizeAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kOpenAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kIsDeferredAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kCanFileMessagesAtom = nsnull;
static const PRUint32 kDisplayBlankCount = 0xFFFFFFFE;
static const PRUint32 kDisplayQuestionCount = 0xFFFFFFFF;
@ -197,6 +199,8 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
kNameAtom = NS_NewAtom("Name");
kSynchronizeAtom = NS_NewAtom("Synchronize");
kOpenAtom = NS_NewAtom("open");
kIsDeferredAtom = NS_NewAtom("isDeferred");
kCanFileMessagesAtom = NS_NewAtom("canFileMessages");
}
CreateLiterals(rdf);
@ -267,6 +271,8 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
NS_RELEASE(kNameAtom);
NS_RELEASE(kSynchronizeAtom);
NS_RELEASE(kOpenAtom);
NS_RELEASE(kIsDeferredAtom);
NS_RELEASE(kCanFileMessagesAtom);
}
}
@ -407,8 +413,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetSources(nsIRDFResource* property,
PRBool tv,
nsISimpleEnumerator** sources)
{
NS_ASSERTION(PR_FALSE, "not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
@ -846,7 +851,7 @@ nsresult nsMsgFolderDataSource::OnItemAddedOrRemoved(nsIRDFResource *parentItem,
nsCOMPtr<nsIRDFNode> itemNode(do_QueryInterface(item));
if (itemNode)
{
NotifyObservers(parentItem, kNC_Child, itemNode, added, PR_FALSE);
NotifyObservers(parentItem, kNC_Child, itemNode, nsnull, added, PR_FALSE);
}
return NS_OK;
}
@ -905,15 +910,17 @@ nsMsgFolderDataSource::OnItemBoolPropertyChanged(nsIRDFResource *resource,
{
if (newValue != oldValue) {
nsIRDFNode* literalNode = newValue?kTrueLiteral:kFalseLiteral;
if (kNewMessagesAtom == property) {
nsIRDFNode* oldLiteralNode = oldValue?kTrueLiteral:kFalseLiteral;
if (kNewMessagesAtom == property)
NotifyPropertyChanged(resource, kNC_NewMessages, literalNode);
}
else if (kSynchronizeAtom == property) {
else if (kSynchronizeAtom == property)
NotifyPropertyChanged(resource, kNC_Synchronize, literalNode);
}
else if (kOpenAtom == property) {
else if (kOpenAtom == property)
NotifyPropertyChanged(resource, kNC_Open, literalNode);
}
else if (kIsDeferredAtom == property)
NotifyPropertyChanged(resource, kNC_IsDeferred, literalNode, oldLiteralNode);
else if (kCanFileMessagesAtom == property)
NotifyPropertyChanged(resource, kNC_CanFileMessages, literalNode, oldLiteralNode);
}
return NS_OK;

View File

@ -278,10 +278,11 @@ protected:
static nsIAtom* kNameAtom;
static nsIAtom* kSynchronizeAtom;
static nsIAtom* kOpenAtom;
static nsIAtom* kIsDeferredAtom;
static nsrefcnt gFolderResourceRefCnt;
nsCOMPtr<nsISupportsArray> kFolderArcsOutArray;
static nsIAtom* kCanFileMessagesAtom;
nsCOMPtr<nsISupportsArray> kFolderArcsOutArray;
};

View File

@ -365,18 +365,20 @@ nsMsgRDFDataSource::getRDFService()
}
nsresult nsMsgRDFDataSource::NotifyPropertyChanged(nsIRDFResource *resource,
nsIRDFResource *propertyResource,
nsIRDFNode *newNode)
nsIRDFResource *propertyResource,
nsIRDFNode *newNode,
nsIRDFNode *oldNode /* = nsnull */)
{
NotifyObservers(resource, propertyResource, newNode, PR_FALSE, PR_TRUE);
return NS_OK;
NotifyObservers(resource, propertyResource, newNode, oldNode, PR_FALSE, PR_TRUE);
return NS_OK;
}
nsresult nsMsgRDFDataSource::NotifyObservers(nsIRDFResource *subject,
nsIRDFResource *property,
nsIRDFNode *object,
nsIRDFNode *newObject,
nsIRDFNode *oldObject,
PRBool assert, PRBool change)
{
NS_ASSERTION(!(change && assert),
@ -384,7 +386,7 @@ nsresult nsMsgRDFDataSource::NotifyObservers(nsIRDFResource *subject,
if(mObservers)
{
nsMsgRDFNotification note = { this, subject, property, object };
nsMsgRDFNotification note = { this, subject, property, newObject, oldObject };
if(change)
mObservers->EnumerateForwards(changeEnumFunc, &note);
else if (assert)
@ -404,7 +406,7 @@ nsMsgRDFDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
observer->OnAssert(note->datasource,
note->subject,
note->property,
note->object);
note->newObject);
return PR_TRUE;
}
@ -417,7 +419,7 @@ nsMsgRDFDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
observer->OnUnassert(note->datasource,
note->subject,
note->property,
note->object);
note->newObject);
return PR_TRUE;
}
@ -430,7 +432,7 @@ nsMsgRDFDataSource::changeEnumFunc(nsISupports *aElement, void *aData)
observer->OnChange(note->datasource,
note->subject,
note->property,
nsnull, note->object);
note->oldObject, note->newObject);
return PR_TRUE;
}
nsresult

View File

@ -49,7 +49,8 @@ typedef struct _nsMsgRDFNotification {
nsIRDFDataSource *datasource;
nsIRDFResource *subject;
nsIRDFResource *property;
nsIRDFNode *object;
nsIRDFNode *newObject;
nsIRDFNode *oldObject;
} nsMsgRDFNotification;
//Some property declarations

View File

@ -108,6 +108,7 @@ nsIAtom* nsMsgDBFolder::kStatusAtom=nsnull;
nsIAtom* nsMsgDBFolder::kNameAtom=nsnull;
nsIAtom* nsMsgDBFolder::kSynchronizeAtom=nsnull;
nsIAtom* nsMsgDBFolder::kOpenAtom=nsnull;
nsIAtom* nsMsgDBFolder::kIsDeferred=nsnull;
nsICollation * nsMsgDBFolder::gCollationKeyGenerator = nsnull;
@ -145,6 +146,7 @@ const nsStaticAtom nsMsgDBFolder::folder_atoms[] = {
{ "Flagged", &nsMsgDBFolder::kFlaggedAtom },
{ "Synchronize", &nsMsgDBFolder::kSynchronizeAtom },
{ "open", &nsMsgDBFolder::kOpenAtom },
{ "isDeferred", &nsMsgDBFolder::kIsDeferred }
};
nsMsgDBFolder::nsMsgDBFolder(void)

View File

@ -238,6 +238,7 @@ protected:
static nsIAtom* kNameAtom;
static nsIAtom* kSynchronizeAtom;
static nsIAtom* kOpenAtom;
static nsIAtom* kIsDeferred;
static nsICollation* gCollationKeyGenerator;
#ifdef MSG_FASTER_URI_PARSING

View File

@ -55,6 +55,10 @@
#include "nsIMsgLocalMailFolder.h"
#include "nsIMsgAccountManager.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsIRDFResource.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
static NS_DEFINE_CID(kCPop3ServiceCID, NS_POP3SERVICE_CID);
class nsPop3GetMailChainer : public nsIUrlListener
@ -126,14 +130,86 @@ NS_IMPL_SERVERPREF_INT(nsPop3IncomingServer,
"num_days_to_leave_on_server")
NS_IMPL_SERVERPREF_STR(nsPop3IncomingServer,
DeferredToAccount,
"deferred_to_account")
NS_IMPL_SERVERPREF_BOOL(nsPop3IncomingServer,
DeferGetNewMail,
"defer_get_new_mail")
NS_IMETHODIMP nsPop3IncomingServer::GetDeferredToAccount(char **aRetVal)
{
return GetCharValue("deferred_to_account", aRetVal);
}
NS_IMETHODIMP nsPop3IncomingServer::SetDeferredToAccount(const char *aAccountKey)
{
nsXPIDLCString deferredToAccount;
GetDeferredToAccount(getter_Copies(deferredToAccount));
//Notify listeners who listen to every folder
nsresult rv = SetCharValue("deferred_to_account", aAccountKey);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFolderListener> folderListenerManager =
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgFolder> rootFolder;
// use GetRootFolder, because that returns the real
// root, not the deferred to root.
rv = GetRootFolder(getter_AddRefs(rootFolder));
if (rootFolder)
{
// if isDeferred state has changed, send notification
if (((aAccountKey && *aAccountKey) == deferredToAccount.IsEmpty()))
{
nsCOMPtr <nsIRDFResource> folderRes = do_QueryInterface(rootFolder);
nsCOMPtr <nsIAtom> deferAtom = getter_AddRefs(NS_NewAtom("isDeferred"));
nsCOMPtr <nsIAtom> canFileAtom = getter_AddRefs(NS_NewAtom("CanFileMessages"));
folderListenerManager->OnItemBoolPropertyChanged(folderRes, deferAtom,
!deferredToAccount.IsEmpty(), deferredToAccount.IsEmpty());
folderListenerManager->OnItemBoolPropertyChanged(folderRes, canFileAtom,
deferredToAccount.IsEmpty(), !deferredToAccount.IsEmpty());
// this hack causes the account manager ds to send notifications to the
// xul content builder that make the changed acct appear or disappear
// from the folder pane and related menus.
nsCOMPtr<nsIMsgAccountManager> acctMgr =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID);
if (acctMgr)
{
acctMgr->NotifyServerUnloaded(this);
acctMgr->NotifyServerLoaded(this);
// check if this newly deferred to account is the local folders account
// and needs to have a newly created INBOX.
if (aAccountKey)
{
nsCOMPtr <nsIMsgAccount> account;
acctMgr->GetAccount(aAccountKey, getter_AddRefs(account));
if (account)
{
nsCOMPtr <nsIMsgIncomingServer> server;
account->GetIncomingServer(getter_AddRefs(server));
if (server)
{
nsCOMPtr <nsILocalMailIncomingServer> incomingLocalServer = do_QueryInterface(server);
if (incomingLocalServer)
{
nsCOMPtr <nsIMsgFolder> rootFolder;
rv = server->GetRootFolder(getter_AddRefs(rootFolder));
NS_ENSURE_SUCCESS(rv, rv);
// this will fail if it already exists, which is fine.
rootFolder->CreateSubfolder(NS_LITERAL_STRING("Inbox").get(), nsnull);
}
}
}
}
}
}
}
}
return rv;
}
//NS_IMPL_GETSET(nsPop3IncomingServer, Authenticated, PRBool, m_authenticated);
NS_IMETHODIMP nsPop3IncomingServer::GetAuthenticated(PRBool *aAuthenticated)
@ -167,7 +243,7 @@ nsresult
nsPop3IncomingServer::GetLocalStoreType(char **type)
{
NS_ENSURE_ARG_POINTER(type);
*type = nsCRT::strdup("mailbox");
*type = strdup("mailbox");
return NS_OK;
}
@ -348,6 +424,18 @@ nsPop3IncomingServer::GetCanFileMessagesOnServer(PRBool *aCanFileMessagesOnServe
return NS_OK;
}
NS_IMETHODIMP
nsPop3IncomingServer::GetCanCreateFoldersOnServer(PRBool *aCanCreateFoldersOnServer)
{
NS_ENSURE_ARG_POINTER(aCanCreateFoldersOnServer);
nsXPIDLCString deferredToAccount;
GetDeferredToAccount(getter_Copies(deferredToAccount));
*aCanCreateFoldersOnServer = deferredToAccount.IsEmpty();
return NS_OK;
}
NS_IMETHODIMP nsPop3IncomingServer::DownloadMailFromServers(nsISupportsArray *aServers,
nsIMsgWindow *aMsgWindow,
nsIMsgFolder *aFolder,

View File

@ -67,6 +67,7 @@ public:
NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
NS_IMETHOD GetRootMsgFolder(nsIMsgFolder **aRootMsgFolder);
NS_IMETHOD GetCanFileMessagesOnServer(PRBool *aCanFileMessagesOnServer);
NS_IMETHOD GetCanCreateFoldersOnServer(PRBool *aCanCreateFoldersOnServer);
NS_IMETHOD GetNewMessages(nsIMsgFolder *aFolder, nsIMsgWindow *aMsgWindow,
nsIUrlListener *aUrlListener);