Fixing bugs 76388, 79561. This fix introduces a generalized procedure to query a given server for it's offline support level. Offline settings item is added to AccountCentral based on server's offline capability. New checkbox item to make messages in the Inbox available when user works offline is added to IMAP offline settings panel. Offline items are hidden in AccountCentral and AccountManager for those ISPs who does not support this feature. Also, offline panel items have been grouped under offline and disk space sections. Minor UI cleanup by fixing some of the sentences on these panels. r=bienvenu,jglick sr=sspitzer

This commit is contained in:
racham%netscape.com 2001-05-19 01:38:51 +00:00
Родитель c57d421c24
Коммит 8b68736eae
15 изменённых файлов: 193 добавлений и 25 удалений

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

@ -21,6 +21,7 @@
var gIncomingServer;
var gServerType;
var gImapIncomingServer;
function onInit()
{
@ -49,6 +50,11 @@ function initServerSettings()
else
document.getElementById("offline.notDownloadMin").setAttribute("value", "50");
if(gServerType == "imap") {
gImapIncomingServer = gIncomingServer.QueryInterface(Components.interfaces.nsIImapIncomingServer);
document.getElementById("offline.downloadBodiesOnGetNewMail").checked = gImapIncomingServer.downloadBodiesOnGetNewMail;
document.getElementById("offline.newFolder").checked = gImapIncomingServer.offlineDownload;
}
}
function initRetentionSettings()
@ -212,5 +218,9 @@ function onSave()
gIncomingServer.retentionSettings = retentionSettings;
gIncomingServer.downloadSettings = downloadSettings;
if (gImapIncomingServer) {
gImapIncomingServer.downloadBodiesOnGetNewMail = document.getElementById("offline.downloadBodiesOnGetNewMail").checked;
gImapIncomingServer.offlineDownload = document.getElementById("offline.newFolder").checked;
}
}

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

@ -42,32 +42,56 @@ Contributors:
<box class="box-smallheader" title="&offlineSettings.label;"/>
<titledbox orient="vertical" id="offline.titlebox">
<titledbox orient="vertical" id="offlinepop.titlebox" hidable="true" hidefor="imap,nntp">
<html iscontrolcontainer="true">&offlinePopDesc.label;</html>
<box iscontrolcontainer="true" orient="horizontal" autostretch="never">
<checkbox wsm_persist="true" id="offline.notDownload"
label="&offlineNotDownload.label;" accesskey="&offlineNotDownload.accesskey;"/>
<textbox wsm_persist="true" id="offline.notDownloadMin" size="5" value="50"/>
<text class="label" value="&kb.label;"/>
</box>
<html iscontrolcontainer="true" hidable="true" hidefor="pop3">&offlineDesc.label;</html>
<html iscontrolcontainer="true" hidable="true" hidefor="imap,nntp">&offlinePopDesc.label;</html>
<box iscontrolcontainer="true" orient="horizontal" autostretch="never">
<checkbox wsm_persist="true" id="offline.compactFolder"
label="&offlineCompact.label;" accesskey="&offlineCompact.accesskey;"/>
<textbox wsm_persist="true" id="offline.compactFolderMin" size="5" value="100"/>
<text class="label" value="&kb.label;"/>
</box>
</titledbox>
<titledbox orient="vertical" id="offline.titlebox" hidable="true" hidefor="pop3">
<label value="&offlineGroupTitle.label;"/>
<html iscontrolcontainer="true" hidable="true" hidefor="pop3,nntp">&offlineImapDesc.label;</html>
<html iscontrolcontainer="true" hidable="true" hidefor="pop3,imap">&offlineNntpDesc.label;</html>
<checkbox iscontrolcontainer="true" hidable="true" hidefor="pop3,nntp"
id="offline.downloadBodiesOnGetNewMail" wsm_persist="true"
label="&makeInboxMsgsAvailable.label;"
accesskey="&makeInboxMsgsAvailable.accesskey;"/>
<checkbox iscontrolcontainer="true" hidable="true" hidefor="pop3,nntp"
id="offline.newFolder" label="&offlineNewFolder.label;"
accesskey="&offlineNewFolder.accesskey;"/>
<separator class="thin" hidable="true" hidefor="pop3,nntp"/>
<html iscontrolcontainer="true" hidable="true" hidefor="pop3,nntp">&selectButtonDesc.label;</html>
<box iscontrolcontainer="true" hidable="true" hidefor="pop3" orient="horizontal" align="right">
<button label="&offlineSelect.label;" oncommand="onClickSelect()"/>
</box>
</titledbox>
<separator class="thin"/>
<titledbox orient="vertical" id="diskspace.titlebox" hidable="true" hidefor="pop3">
<label value="&diskspaceGroupTitle.label;"/>
<checkbox iscontrolcontainer="true" hidable="true" hidefor="pop3,nntp" id="offline.newFolder"
label="&offlineNewFolder.label;" accesskey="&offlineNewFolder.accesskey;"/>
<separator class="thin"/>
<html iscontrolcontainer="true" hidable="true" hidefor="pop3">&offlineMsg.label;</html>
<box iscontrolcontainer="true" hidable="true" hidefor="pop3,nntp" orient="horizontal">
<checkbox wsm_persist="true" id="offline.removeMsg"
label="&offlineRemove.label;" accesskey="&offlineRemove.accesskey;"/>
<textbox wsm_persist="true" id="offline.removeMsgMin" size="5" value="30"/>
<text class="label" value="&days.label;"/>
</box>
<box iscontrolcontainer="true" orient="horizontal" autostretch="never">
<checkbox wsm_persist="true" id="offline.notDownload"
<checkbox wsm_persist="true" id="offline.notDownload"
label="&offlineNotDownload.label;" accesskey="&offlineNotDownload.accesskey;"/>
<textbox wsm_persist="true" id="offline.notDownloadMin" size="5" value="50"/>
<text class="label" value="&kb.label;"/>
@ -112,9 +136,7 @@ Contributors:
<textbox wsm_persist="true" id="nntp.removeBodyMin" size="5" value="30"/>
<text class="label" value="&days.label;"/>
</box>
<separator/>
</box>
</titledbox>
</window>

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

@ -1,12 +1,10 @@
<!ENTITY offlineSettings.label "Offline &amp; Disk Space">
<!ENTITY offlineDesc.label "Offline enables you to download your messages locally so that they are available when you are disconnected from the server. Use the &quot;Select&quot; button to choose which messages will be available when you are offline.">
<!ENTITY offlinePopDesc.label "Messages are stored locally on your computer. Use the following settings to save disk space.">
<!ENTITY offlinePopDesc.label "Messages are stored locally on your computer. To save disk space:">
<!ENTITY offlineMsg.label "To save download time and disk space:">
<!ENTITY offlineNewFolder.label "When I create new folders, select them for offline">
<!ENTITY offlineNewFolder.accesskey "h">
<!ENTITY offlineRemove.label "Remove message bodies only older than">
<!ENTITY offlineRemove.accesskey "r">
<!ENTITY offlineNotDownload.label "Do not download message bodies locally that are larger than">
<!ENTITY offlineNotDownload.label "Do not download messages locally that are larger than">
<!ENTITY offlineNotDownload.accesskey "d">
<!ENTITY offlineCompact.label "Compact folders when it will save over">
<!ENTITY offlineCompact.accesskey "c">
@ -14,9 +12,9 @@
<!ENTITY days.label "days">
<!ENTITY daysAgo.label "days ago">
<!ENTITY message.label "messages">
<!ENTITY nntpDownloadUnread.label "Download only unread messages">
<!ENTITY nntpDownloadUnread.label "Download only unread message bodies">
<!ENTITY nntpDownloadUnread.accesskey "u">
<!ENTITY nntpDownloadMsg.label "Download only messages since">
<!ENTITY nntpDownloadMsg.label "Download message bodies for messages since">
<!ENTITY nntpDownloadMsg.accesskey "o">
<!ENTITY nntpCleanup.label "When it is time to clean up messages:">
<!ENTITY nntpKeepMsg.label "Keep messages which have arrived within the past">
@ -35,3 +33,5 @@
<!ENTITY selectButtonDesc.label "Use the &quot;Select&quot; button to choose which folders will be available when you are working offline.">
<!ENTITY makeInboxMsgsAvailable.label "Make the messages in my Inbox available when I am working offline">
<!ENTITY makeInboxMsgsAvailable.accesskey "b">
<!ENTITY offlineGroupTitle.label "Offline">
<!ENTITY diskspaceGroupTitle.label "Disk Space">

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

@ -216,6 +216,22 @@ interface nsIMsgIncomingServer : nsISupports {
/* display startup page once per account per session */
attribute boolean displayStartupPage;
attribute nsIMsgDownloadSettings downloadSettings;
/*
* Offline support level. Support level can vary based on abilities
* and features each server can offer wrt to offline service.
* Here is the legend to determine the each support level details
*
* supportLevel == 0 --> no offline support (default)
* supportLevel == 10 --> regular offline feature support
* supportLevel == 20 --> extended offline feature support
*
* Each server can initialize itself to the support level if needed
* to override the default choice i.e., no offline support.
* IMAP and POP3 servers are set with level 10 and NEWS with level 20.
* None and Movemail will default to 0.
*/
attribute long offlineSupportLevel;
};
%{C++

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

@ -138,8 +138,12 @@ function ArrangeAccountCentralItems(server, protocolInfo, msgFolder)
// Create Filters
var canHaveFilters = server.canHaveFilters;
SetItemDisplay("CreateFilters", canHaveFilters);
// Offline Settings
var supportsOffline = (server.offlineSupportLevel != 0);
SetItemDisplay("OfflineSettings", supportsOffline);
var displayAdvFeatures = canSearchMessages || canHaveFilters;
var displayAdvFeatures = canSearchMessages || canHaveFilters || supportsOffline;
// Display Adv Features header, only if any of the items are displayed
SetItemDisplay("AdvancedFeaturesHeader", displayAdvFeatures);

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

@ -138,6 +138,12 @@ Rights Reserved.
</box>
</row>
<separator id="CreateFilters.separator" class="thin"/>
<row id="OfflineSettings" class="acctCentralRow">
<box>
<text class="acctCentralText acctCentralLinkText" value="&offlineLink.label;" onclick="ViewSettings();"/>
</box>
</row>
<separator id="OfflineSettings.separator" class="thin"/>
</rows>
</grid>

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

@ -40,6 +40,7 @@
#include "nsMsgRDFUtils.h"
#include "nsIMsgFolder.h"
#include "nsMsgBaseCID.h"
#include "nsMsgIncomingServer.h"
// turn this on to see useful output
#undef DEBUG_amds
@ -525,7 +526,13 @@ nsMsgAccountManagerDataSource::createSettingsResources(nsIRDFResource *aSource,
if (hasIdentities) {
aNodeArray->AppendElement(kNC_PageTitleServer);
aNodeArray->AppendElement(kNC_PageTitleCopies);
aNodeArray->AppendElement(kNC_PageTitleOffline);
// Check the offline capability before adding
// offline item
PRInt32 offlineSupportLevel = 0;
server->GetOfflineSupportLevel(&offlineSupportLevel);
if (offlineSupportLevel >= OFFLINE_SUPPORT_LEVEL_REGULAR)
aNodeArray->AppendElement(kNC_PageTitleOffline);
}
}
}

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

@ -1267,6 +1267,27 @@ NS_IMETHODIMP nsMsgIncomingServer::SetDownloadSettings(nsIMsgDownloadSettings *s
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::GetOfflineSupportLevel(PRInt32 *aSupportLevel)
{
NS_ENSURE_ARG_POINTER(aSupportLevel);
nsresult rv;
rv = GetIntValue("offline_support_level", aSupportLevel);
if (*aSupportLevel != OFFLINE_SUPPORT_LEVEL_UNDEFINED) return rv;
// set default value
*aSupportLevel = OFFLINE_SUPPORT_LEVEL_NONE;
return NS_OK;
}
NS_IMETHODIMP
nsMsgIncomingServer::SetOfflineSupportLevel(PRInt32 aSupportLevel)
{
SetIntValue("offline_support_level", aSupportLevel);
return NS_OK;
}
#define BASE_MSGS_URL "chrome://messenger/locale/messenger.properties"
NS_IMETHODIMP nsMsgIncomingServer::DisplayOfflineMsg(nsIMsgWindow *aMsgWindow)

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

@ -32,6 +32,26 @@
#include "nsWeakReference.h"
#include "nsIMsgDatabase.h"
/*
* Following values for offline support have been used by
* various files. If you are modifying any of the values
* below, please do take care of the following files.
* - mozilla/mailnews/base/src/nsMsgAccountManagerDS.cpp
* - mozilla/mailnews/base/util/nsMsgIncomingServer.cpp
* - mozilla/mailnews/imap/src/nsImapIncomingServer.cpp
* - mozilla/mailnews/local/src/nsPop3IncomingServer.cpp
* - mozilla/mailnews/news/src/nsNntpIncomingServer.cpp
* - mozilla/mailnews/base/resources/content/msgAccountCentral.js
* - mozilla/modules/libpref/src/init/mailnews.js
* - ns/modules/libpref/src/init/mailnews-ns.js
* - ns/mailnews/base/ispdata/aol.rdf
* - ns/mailnews/base/ispdata/nswebmail.rdf
*/
#define OFFLINE_SUPPORT_LEVEL_NONE 0
#define OFFLINE_SUPPORT_LEVEL_REGULAR 10
#define OFFLINE_SUPPORT_LEVEL_EXTENDED 20
#define OFFLINE_SUPPORT_LEVEL_UNDEFINED -1
class nsIMsgFolderCache;
class nsIMsgProtocolInfo;

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

@ -2792,3 +2792,35 @@ nsImapIncomingServer::GetCanSearchMessages(PRBool *canSearchMessages)
return NS_OK;
}
NS_IMETHODIMP
nsImapIncomingServer::GetOfflineSupportLevel(PRInt32 *aSupportLevel)
{
NS_ENSURE_ARG_POINTER(aSupportLevel);
nsresult rv = NS_OK;
rv = GetIntValue("offline_support_level", aSupportLevel);
if (*aSupportLevel != OFFLINE_SUPPORT_LEVEL_UNDEFINED) return rv;
nsCAutoString prefName("default_offline_support_level");
nsXPIDLCString hostName;
GetHostName(getter_Copies(hostName));
if (hostName.get()) {
prefName.Append(".");
prefName.Append(hostName);
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
if(NS_SUCCEEDED(rv)) {
rv = prefs->GetIntPref(prefName, aSupportLevel);
}
}
// Couldn't get the pref value with the hostname.
// Fall back on IMAP default value
if (NS_FAILED(rv)) {
// set default value
*aSupportLevel = OFFLINE_SUPPORT_LEVEL_REGULAR;
}
return NS_OK;
}

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

@ -64,6 +64,7 @@ public:
NS_IMETHOD GetConstructedPrettyName(PRUnichar **retval);
NS_IMETHOD GetCanBeDefaultServer(PRBool *canBeDefaultServer);
NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
protected:
nsresult GetFolder(const char* name, nsIMsgFolder** pFolder);

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

@ -316,3 +316,16 @@ nsPop3IncomingServer::GetCanSearchMessages(PRBool *canSearchMessages)
return NS_OK;
}
NS_IMETHODIMP
nsPop3IncomingServer::GetOfflineSupportLevel(PRInt32 *aSupportLevel)
{
NS_ENSURE_ARG_POINTER(aSupportLevel);
nsresult rv;
rv = GetIntValue("offline_support_level", aSupportLevel);
if (*aSupportLevel != OFFLINE_SUPPORT_LEVEL_UNDEFINED) return rv;
// set default value
*aSupportLevel = OFFLINE_SUPPORT_LEVEL_REGULAR;
return NS_OK;
}

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

@ -47,6 +47,7 @@ public:
NS_IMETHOD GetDownloadMessagesAtStartup(PRBool *getMessages);
NS_IMETHOD GetCanBeDefaultServer(PRBool *canBeDefaultServer);
NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
private:
static nsresult setSubFolderFlag(nsIFolder *aRootFolder,

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

@ -1551,3 +1551,17 @@ nsNntpIncomingServer::GetCanSearchMessages(PRBool *canSearchMessages)
*canSearchMessages = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::GetOfflineSupportLevel(PRInt32 *aSupportLevel)
{
NS_ENSURE_ARG_POINTER(aSupportLevel);
nsresult rv;
rv = GetIntValue("offline_support_level", aSupportLevel);
if (*aSupportLevel != OFFLINE_SUPPORT_LEVEL_UNDEFINED) return rv;
// set default value
*aSupportLevel = OFFLINE_SUPPORT_LEVEL_EXTENDED;
return NS_OK;
}

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

@ -73,6 +73,7 @@ public:
// override to clear all passwords associated with server
NS_IMETHODIMP ForgetPassword();
NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
protected:
nsresult CreateProtocolInstance(nsINNTPProtocol ** aNntpConnection, nsIURI *url,