Bug 297534: Want to entirely disable marking a message as read when viewed

r=mnyromyr, sr=bienvenu


git-svn-id: svn://10.0.0.236/trunk@252869 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mkmelin+mozilla%iki.fi 2008-07-06 21:50:39 +00:00
parent 249c10a257
commit 2e3ca7e893
10 changed files with 201 additions and 104 deletions

View File

@ -2666,9 +2666,9 @@ function OnMsgLoaded(aUrl)
folder = aUrl.folder;
}
catch (ex) {}
var msgURI = GetLoadedMessage();
if (!folder || !msgURI)
return;
@ -2683,22 +2683,30 @@ function OnMsgLoaded(aUrl)
gNextMessageViewIndexAfterDelete = -2;
var msgHdr = msgHdrForCurrentMessage();
gMessageNotificationBar.setJunkMsg(msgHdr);
// we just finished loading a message. set a timer to actually mark the message is read after n seconds
var markReadAutoMode = gPrefBranch.getBoolPref("mailnews.mark_message_read.auto");
// We just finished loading a message. If messages are to be marked as read
// automatically, set a timer to mark the message is read after n seconds
// where n can be configured by the user.
var markReadOnADelay = gPrefBranch.getBoolPref("mailnews.mark_message_read.delay");
if (msgHdr && !msgHdr.isRead)
if (msgHdr && !msgHdr.isRead && markReadAutoMode)
{
if (markReadOnADelay && wintype == "mail:3pane") // only use the timer if viewing using the 3-pane preview pane and the user has set the pref
let markReadOnADelay = gPrefBranch.getBoolPref("mailnews.mark_message_read.delay");
// Only use the timer if viewing using the 3-pane preview pane and the
// user has set the pref.
if (markReadOnADelay && wintype == "mail:3pane") // 3-pane window
{
ClearPendingReadTimer();
gMarkViewedMessageAsReadTimer = setTimeout(MarkCurrentMessageAsRead, gPrefBranch.getIntPref("mailnews.mark_message_read.delay.interval") * 1000);
let markReadDelayTime = gPrefBranch.getIntPref("mailnews.mark_message_read.delay.interval");
if (markReadDelayTime == 0)
MarkCurrentMessageAsRead();
else
gMarkViewedMessageAsReadTimer = setTimeout(MarkCurrentMessageAsRead,
markReadDelayTime * 1000);
}
else
else // standalone msg window
MarkCurrentMessageAsRead();
}

View File

@ -43,12 +43,13 @@ var gAdvancedPane = {
init: function ()
{
this.mPane = document.getElementById("paneAdvanced");
this.updateMarkAsReadOptions(document.getElementById("automaticallyMarkAsRead").checked);
this.updateMarkAsReadTextbox(false);
if ("arguments" in window && window.arguments[1] && document.getElementById(window.arguments[1]))
document.getElementById("advancedPrefs").selectedTab = document.getElementById(window.arguments[1]);
else
{
{
var preference = document.getElementById("mail.preferences.advanced.selectedTabIndex");
if (preference.value)
document.getElementById("advancedPrefs").selectedIndex = preference.value;
@ -112,7 +113,7 @@ var gAdvancedPane = {
* ii f t/f true
* iii 0/1/2 f false
* iii 0/1/2 t true
*
*
*/
updateAppUpdateItems: function ()
{
@ -125,15 +126,15 @@ var gAdvancedPane = {
enableAppUpdate.disabled = !aus.canUpdate || enabledPref.locked;
},
updateAutoItems: function ()
{
var enabledPref = document.getElementById("app.update.enabled");
var autoPref = document.getElementById("app.update.auto");
var updateModeLabel = document.getElementById("updateModeLabel");
var updateMode = document.getElementById("updateMode");
var disable = enabledPref.locked || !enabledPref.value ||
autoPref.locked;
updateModeLabel.disabled = updateMode.disabled = disable;
@ -144,9 +145,9 @@ var gAdvancedPane = {
var enabledPref = document.getElementById("app.update.enabled");
var autoPref = document.getElementById("app.update.auto");
var modePref = document.getElementById("app.update.mode");
var warnIncompatible = document.getElementById("warnIncompatible");
var disable = enabledPref.locked || !enabledPref.value || autoPref.locked ||
!autoPref.value || modePref.locked;
warnIncompatible.disabled = disable;
@ -182,13 +183,13 @@ var gAdvancedPane = {
gAdvancedPane._modePreference = doNotWarn ? preference.value : 1;
return doNotWarn;
},
addonWarnSyncTo: function ()
{
var warnIncompatible = document.getElementById("warnIncompatible");
return !warnIncompatible.checked ? 0 : gAdvancedPane._modePreference;
},
showUpdates: function ()
{
var prompter = Components.classes["@mozilla.org/updates/update-prompt;1"]
@ -196,15 +197,23 @@ var gAdvancedPane = {
prompter.showUpdateHistory(window);
},
updateMarkAsReadTextbox: function(aFocusTextBox)
updateMarkAsReadOptions: function(enableRadioGroup)
{
var textbox = document.getElementById('markAsReadDelay');
textbox.disabled = !document.getElementById('markAsRead').checked;
document.getElementById('markAsReadAutoPreferences').disabled = !enableRadioGroup;
// ... and the extras!
document.getElementById('markAsReadDelay').disabled = !enableRadioGroup;
document.getElementById('secondsLabel').disabled = !enableRadioGroup;
},
updateMarkAsReadTextbox: function(aFocusTextBox)
{
var textbox = document.getElementById('markAsReadDelay');
textbox.disabled = !document.getElementById('markAsReadAfterDelay').selected;
if (!textbox.disabled && aFocusTextBox)
textbox.focus();
},
/**
/**
* open the return receipts configuration dialog
*/
showReturnReceipts: function()
@ -212,7 +221,7 @@ var gAdvancedPane = {
document.documentElement.openSubDialog("chrome://messenger/content/preferences/receipts.xul",
"", null);
},
/**
* open the connections dialog
*/
@ -222,8 +231,8 @@ var gAdvancedPane = {
.openSubDialog("chrome://messenger/content/preferences/connection.xul",
"", null);
},
/**
/**
* open the offline settings dialog
*/
showOffline: function()
@ -232,25 +241,25 @@ var gAdvancedPane = {
.openSubDialog("chrome://messenger/content/preferences/offline.xul",
"", null);
},
showCertificates: function ()
{
document.documentElement.openWindow("mozilla:certmanager", "chrome://pippki/content/certManager.xul",
"width=600,height=400", null);
},
showCRLs: function ()
{
document.documentElement.openWindow("Mozilla:CRLManager", "chrome://pippki/content/crlManager.xul",
"width=600,height=400", null);
},
showOCSP: function ()
{
document.documentElement.openSubDialog("chrome://mozapps/content/preferences/ocsp.xul",
"", null);
},
showSecurityDevices: function ()
{
document.documentElement.openWindow("mozilla:devicemanager", "chrome://pippki/content/device_manager.xul",

View File

@ -55,8 +55,13 @@
name="mail.preferences.advanced.selectedTabIndex" type="int"/>
<preference id="mail.showCondensedAddresses" name="mail.showCondensedAddresses" type="bool"/>
<preference id="mailnews.remember_selected_message" name="mailnews.remember_selected_message" type="bool"/>
<preference id="mailnews.mark_message_read.delay" name="mailnews.mark_message_read.delay" type="bool"/>
<preference id="mailnews.mark_message_read.delay.interval" name="mailnews.mark_message_read.delay.interval" type="int"/>
<preference id="mailnews.mark_message_read.auto"
name="mailnews.mark_message_read.auto" type="bool"/>
<preference id="mailnews.mark_message_read.delay"
name="mailnews.mark_message_read.delay" type="bool"
onchange="gAdvancedPane.updateMarkAsReadTextbox(this.value);"/>
<preference id="mailnews.mark_message_read.delay.interval"
name="mailnews.mark_message_read.delay.interval" type="int"/>
<preference id="mail.showFolderPaneColumns" name="mail.showFolderPaneColumns" type="bool"/>
<preference id="mailnews.reuse_message_window" name="mailnews.reuse_message_window" type="bool"/>
<preference id="mailnews.tcptimeout" name="mailnews.tcptimeout" type="int"/>
@ -102,13 +107,33 @@
accesskey="&showCondensedAddresses.accesskey;" preference="mail.showCondensedAddresses"/>
</hbox>
<hbox align="center" pack="start">
<checkbox id="markAsRead" label="&markAsRead.label;" accesskey="&markAsRead.accesskey;"
preference="mailnews.mark_message_read.delay"
oncommand="gAdvancedPane.updateMarkAsReadTextbox(true);"/>
<textbox id="markAsReadDelay" size="2" preference="mailnews.mark_message_read.delay.interval" aria-labelledby="markAsRead markAsReadDelay markAsReadEnd"/>
<label id="markAsReadEnd" value="&markAsReadEnd.label;"/>
</hbox>
<vbox>
<hbox align="center" pack="start">
<checkbox id="automaticallyMarkAsRead"
preference="mailnews.mark_message_read.auto"
label="&autoMarkAsRead.label;"
accesskey="&autoMarkAsRead.accesskey;"
oncommand="gAdvancedPane.updateMarkAsReadOptions(this.checked)"/>
</hbox>
<hbox class="indent">
<radiogroup id="markAsReadAutoPreferences" orient="vertical"
preference="mailnews.mark_message_read.delay">
<radio id="mark_read_immediately" value="false"
label="&markAsReadNoDelay.label;"
accesskey="&markAsReadNoDelay.accesskey;"/>
<hbox align="center" pack="start">
<radio id="markAsReadAfterDelay" value="true"
label="&markAsReadDelay.label;"
accesskey="&markAsReadDelay.accesskey;"/>
<textbox id="markAsReadDelay" size="2"
preference="mailnews.mark_message_read.delay.interval"
aria-labelledby="markAsReadAfterDelay markAsReadDelay secondsLabel"/>
<label id="secondsLabel" value="&secondsLabel.label;"/>
</hbox>
</radiogroup>
</hbox>
</vbox>
<hbox align="center" pack="start">
<checkbox id="mailRememberLastMsg" label="&rememberLastMsg.label;"

View File

@ -8,12 +8,16 @@
<!ENTITY showCondensedAddresses.label "Show only display name for people in my address book">
<!ENTITY showCondensedAddresses.accesskey "p">
<!-- LOCALIZATION NOTE (markAsRead.label): This will concatenate with
"xxx seconds before marking a message as read", using a number and
(markAsReadEnd.label). -->
<!ENTITY markAsRead.label "Wait">
<!ENTITY markAsRead.accesskey "W">
<!ENTITY markAsReadEnd.label "seconds before marking a message as read">
<!ENTITY autoMarkAsRead.label "Automatically mark messages as read">
<!ENTITY autoMarkAsRead.accesskey "A">
<!ENTITY markAsReadNoDelay.label "Immediately on display">
<!ENTITY markAsReadNoDelay.accesskey "d">
<!-- LOCALIZATION NOTE (markAsReadDelay.label): This will concatenate to
"After displaying for [___] seconds",
using (markAsReadDelay.label) and a number (secondsLabel.label). -->
<!ENTITY markAsReadDelay.label "After displaying for">
<!ENTITY markAsReadDelay.accesskey "e">
<!ENTITY secondsLabel.label "seconds">
<!ENTITY showFolderColumns.label "Show expanded columns in the folder pane">
<!ENTITY showFolderColumns.accesskey "l">
<!ENTITY rememberLastMsg.label "Remember the last selected message">

View File

@ -40,12 +40,21 @@
function Startup()
{
let value = document.getElementById("mailnews.mark_message_read.delay").value;
EnableTextbox("markMessagesReadAfter", value, false);
var autoMark = document.getElementById("mailnews.mark_message_read.auto").value;
UpdateMarkAsReadOptions(autoMark);
UpdateMarkAsReadDelayTextbox(false);
}
function EnableMarkMessagesReadAfter(aValue)
function UpdateMarkAsReadOptions(enableRadioGroup)
{
let focus = (document.getElementById("markMessagesRead") == document.commandDispatcher.focusedElement);
EnableTextbox("markMessagesReadAfter", aValue, focus);
document.getElementById('markAsReadAutoPreferences').disabled = !enableRadioGroup;
// ... and the extras!
document.getElementById('markAsReadDelay').disabled = !enableRadioGroup;
document.getElementById('secondsLabel').disabled = !enableRadioGroup;
}
function UpdateMarkAsReadDelayTextbox(focusTextBox)
{
var enable = document.getElementById('markAsReadAfterDelay').selected;
EnableTextbox("markAsReadDelay", enable, focusTextBox);
}

View File

@ -51,10 +51,13 @@
<preference id="mailnews.message_display.disable_remote_image"
name="mailnews.message_display.disable_remote_image"
type="bool"/>
<preference id="mailnews.mark_message_read.auto"
name="mailnews.mark_message_read.auto"
type="bool"/>
<preference id="mailnews.mark_message_read.delay"
name="mailnews.mark_message_read.delay"
type="bool"
onchange="EnableMarkMessagesReadAfter(this.value);"/>
onchange="UpdateMarkAsReadDelayTextbox(this.value);"/>
<preference id="mailnews.mark_message_read.delay.interval"
name="mailnews.mark_message_read.delay.interval"
type="int"/>
@ -99,16 +102,33 @@
<separator class="thin"/>
<hbox align="center">
<checkbox id="markMessagesRead" label="&markMessagesRead.label;"
accesskey="&markMessagesRead.accesskey;"
preference="mailnews.mark_message_read.delay"
aria-labelledby="markMessagesRead markMessagesReadAfter secondsLabel"/>
<textbox id="markMessagesReadAfter" size="3" value="5"
preference="mailnews.mark_message_read.delay.interval"
aria-labelledby="markMessagesRead markMessagesReadAfter secondsLabel"/>
<label id="secondsLabel" value="&seconds.label;"/>
</hbox>
<vbox>
<hbox align="center" pack="start">
<checkbox id="automaticallyMarkAsRead"
preference="mailnews.mark_message_read.auto"
label="&autoMarkAsRead.label;"
accesskey="&autoMarkAsRead.accesskey;"
oncommand="UpdateMarkAsReadOptions(this.checked)"/>
</hbox>
<hbox class="indent">
<radiogroup id="markAsReadAutoPreferences" orient="vertical"
preference="mailnews.mark_message_read.delay">
<radio id="mark_read_immediately" value="false"
label="&markAsReadNoDelay.label;"
accesskey="&markAsReadNoDelay.accesskey;"/>
<hbox align="center" pack="start">
<radio id="markAsReadAfterDelay" value="true"
label="&markAsReadDelay.label;"
accesskey="&markAsReadDelay.accesskey;"/>
<textbox id="markAsReadDelay" size="2"
preference="mailnews.mark_message_read.delay.interval"
aria-labelledby="markAsReadAfterDelay markAsReadDelay secondsLabel"/>
<label id="secondsLabel" value="&secondsLabel.label;"/>
</hbox>
</radiogroup>
</hbox>
</vbox>
</groupbox>
<groupbox>

View File

@ -2413,32 +2413,39 @@ function OnMsgLoaded(aUrl)
// if the user clicks on another message then that message stays selected
// and the selection does not "snap back" to the message chosen by
// SetNextMessageAfterDelete() when the operation completes (bug 243532).
var wintype = document.documentElement.getAttribute('windowtype');
gNextMessageViewIndexAfterDelete = -2;
var msgHdr = msgHdrForCurrentMessage();
gMessageNotificationBar.setJunkMsg(msgHdr);
// we just finished loading a message. set a timer to actually mark the message as read after n seconds
var markReadAutoMode = gPrefBranch.getBoolPref("mailnews.mark_message_read.auto");
// We just finished loading a message. If messages are to be marked as read
// automatically, set a timer to mark the message is read after n seconds
// where n can be configured by the user.
var markReadOnADelay = gPrefBranch.getBoolPref("mailnews.mark_message_read.delay");
if (msgHdr && !msgHdr.isRead)
if (msgHdr && !msgHdr.isRead && markReadAutoMode)
{
var wintype = document.documentElement.getAttribute('windowtype');
if (markReadOnADelay && wintype == "mail:3pane") // only use the timer if viewing using the 3-pane preview pane and the user has set the pref
let markReadOnADelay = gPrefBranch.getBoolPref("mailnews.mark_message_read.delay");
// Only use the timer if viewing using the 3-pane preview pane and the
// user has set the pref.
if (markReadOnADelay && wintype == "mail:3pane") // 3-pane window
{
ClearPendingReadTimer();
gMarkViewedMessageAsReadTimer = setTimeout(MarkCurrentMessageAsRead, gPrefBranch.getIntPref("mailnews.mark_message_read.delay.interval") * 1000);
let markReadDelayTime = gPrefBranch.getIntPref("mailnews.mark_message_read.delay.interval");
if (markReadDelayTime == 0)
MarkCurrentMessageAsRead();
else
gMarkViewedMessageAsReadTimer = setTimeout(MarkCurrentMessageAsRead,
markReadDelayTime * 1000);
}
else
{
else // standalone msg window
MarkCurrentMessageAsRead();
}
}
// See if MDN was requested but has not been sent.
HandleMDNResponse(aUrl);
var currentMsgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
if (!IsImapMessage(msgURI))
return;

View File

@ -449,7 +449,7 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char *aMessageURI,
nsCAutoString folderURI;
nsMsgKey key;
nsCAutoString messageURI(aMessageURI);
PRInt32 typeIndex = messageURI.Find("&type=application/x-message-display");
if (typeIndex != kNotFound)
{
@ -470,20 +470,20 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char *aMessageURI,
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(uri, &rv);
if (NS_SUCCEEDED(rv) && mailnewsUrl)
mailnewsUrl->GetLoadGroup(getter_AddRefs(aLoadGroup));
rv = NewChannel(uri, getter_AddRefs(aChannel));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(uri);
// now try to open the channel passing in our display consumer as the listener
return aChannel->AsyncOpen(aStreamListener, aCtxt);
}
}
rv = DecomposeImapURI(messageURI, getter_AddRefs(folder), msgKey);
if (msgKey.IsEmpty())
return NS_MSG_MESSAGE_NOT_FOUND;
rv = nsParseImapMessageURI(aMessageURI, folderURI, &key, getter_Copies(mimePart));
if (NS_SUCCEEDED(rv))
{
@ -500,32 +500,32 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char *aMessageURI,
return FetchMimePart(imapUrl, nsIImapUrl::nsImapMsgFetch, folder, imapMessageSink,
aURL, aDisplayConsumer, msgKey, mimePart);
}
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(imapUrl));
nsCOMPtr<nsIMsgI18NUrl> i18nurl (do_QueryInterface(imapUrl));
i18nurl->SetCharsetOverRide(aCharsetOverride);
PRUint32 messageSize;
PRBool useMimePartsOnDemand = gMIMEOnDemand;
PRBool shouldStoreMsgOffline = PR_FALSE;
PRBool hasMsgOffline = PR_FALSE;
nsCOMPtr<nsIMsgIncomingServer> aMsgIncomingServer;
if (imapMessageSink)
imapMessageSink->GetMessageSizeFromDB(msgKey.get(), PR_TRUE, &messageSize);
msgurl->SetMsgWindow(aMsgWindow);
rv = msgurl->GetServer(getter_AddRefs(aMsgIncomingServer));
if (NS_SUCCEEDED(rv) && aMsgIncomingServer)
{
nsCOMPtr<nsIImapIncomingServer> aImapServer(do_QueryInterface(aMsgIncomingServer, &rv));
if (NS_SUCCEEDED(rv) && aImapServer)
aImapServer->GetMimePartsOnDemand(&useMimePartsOnDemand);
}
nsCAutoString uriStr(aMessageURI);
PRInt32 keySeparator = uriStr.RFindChar('#');
if(keySeparator != -1)
@ -536,13 +536,13 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char *aMessageURI,
if (mpodFetchPos != -1)
useMimePartsOnDemand = PR_FALSE;
}
if (folder)
{
folder->ShouldStoreMsgOffline(key, &shouldStoreMsgOffline);
folder->HasMsgOffline(key, &hasMsgOffline);
}
if (!useMimePartsOnDemand || (messageSize < (uint32) gMIMEOnDemandThreshold))
// allowedToBreakApart &&
// !GetShouldFetchAllParts() &&
@ -564,16 +564,22 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char *aMessageURI,
}
if (imapMessageSink && !hasMsgOffline)
imapMessageSink->SetNotifyDownloadedLines(shouldStoreMsgOffline);
if (hasMsgOffline)
msgurl->SetMsgIsInLocalCache(PR_TRUE);
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
PRBool forcePeek = PR_FALSE; // should the message fetch force a peak or a traditional fetch?
if (NS_SUCCEEDED(rv) && prefBranch)
prefBranch->GetBoolPref("mailnews.mark_message_read.delay", &forcePeek);
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
// Should the message fetch force a peek or a traditional fetch?
// Force peek if there is a delay in marking read.
PRBool forcePeek = PR_FALSE;
if (NS_SUCCEEDED(rv) && prefBranch)
{
PRBool markReadAuto = PR_TRUE;
prefBranch->GetBoolPref("mailnews.mark_message_read.auto", &markReadAuto);
if (markReadAuto)
prefBranch->GetBoolPref("mailnews.mark_message_read.delay", &forcePeek);
}
rv = FetchMessage(imapUrl, forcePeek ? nsIImapUrl::nsImapMsgFetchPeek : nsIImapUrl::nsImapMsgFetch,
folder, imapMessageSink, aMsgWindow, aDisplayConsumer, msgKey, PR_FALSE,
(mPrintingOperation) ? NS_LITERAL_CSTRING("print") : EmptyCString(), aURL);

View File

@ -702,7 +702,12 @@ pref("mail.compose.dontWarnMail2Newsgroup", false);
pref("mail.purge.min_delay", 480);
pref("mail.purge.timer_interval", 5);
// set to true if viewing a message should mark it as read only if the msg is viewed for a specified time interval in seconds
// Set to false if opening a message in the standalone message window or viewing
// it in the message pane should never mark it as read.
pref("mailnews.mark_message_read.auto", true);
// Set to true if viewing a message should mark it as read after the msg is
// viewed in the message pane for a specified time interval in seconds.
pref("mailnews.mark_message_read.delay", false);
pref("mailnews.mark_message_read.delay.interval", 5); // measured in seconds

View File

@ -64,12 +64,16 @@
<!ENTITY convertEmoticons.label "Display emoticons as graphics">
<!ENTITY convertEmoticons.accesskey "D">
<!ENTITY generalMessageDisplay.caption "General">
<!-- LOCALIZATION NOTE (markMessagesRead.label): This will concatenate with
"xxx seconds before marking a message as read", using a number and
(seconds.label). -->
<!ENTITY markMessagesRead.label "Wait">
<!ENTITY markMessagesRead.accesskey "W">
<!ENTITY seconds.label "seconds before marking a message as read">
<!ENTITY autoMarkAsRead.label "Automatically mark messages as read">
<!ENTITY autoMarkAsRead.accesskey "A">
<!ENTITY markAsReadNoDelay.label "Immediately on display">
<!ENTITY markAsReadNoDelay.accesskey "d">
<!-- LOCALIZATION NOTE (markAsReadDelay.label): This will concatenate to
"After displaying for [___] seconds",
using (markAsReadDelay.label) and a number (secondsLabel.label). -->
<!ENTITY markAsReadDelay.label "After displaying for">
<!ENTITY markAsReadDelay.accesskey "e">
<!ENTITY secondsLabel.label "seconds">
<!ENTITY openingMessages.label "When opening messages, display them in:">
<!ENTITY newWindowRadio.label "A new message window">