mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
Bug 340560 Integrate the replication progress dialog into the LDAP directory properties window. r=Neil,sr=bienvenu
This commit is contained in:
parent
084d044d7d
commit
29f46b3181
@ -68,8 +68,6 @@
|
||||
<!ENTITY return.accesskey "r">
|
||||
<!ENTITY results.label "results">
|
||||
<!ENTITY offlineText.label "You can download a local copy of this directory so that it is available for use when you are working offline.">
|
||||
<!ENTITY downloadNowButton.label "Download Now">
|
||||
<!ENTITY downloadNowButton.accesskey "D">
|
||||
<!-- Localization note: this is here because the width of the dialog
|
||||
is determined by the width of the base DN box; and that is likely
|
||||
to vary somewhat with the language.
|
||||
|
@ -39,17 +39,12 @@ replicationStarted=Replication started...
|
||||
changesStarted=Started finding changes to replicate...
|
||||
replicationSucceeded=Replication succeeded
|
||||
replicationFailed=Replication failed
|
||||
replicationCancelled=Replication cancelled
|
||||
# LOCALIZATION NOTE
|
||||
# do not localize %S. %S is the current entry number (an integer)
|
||||
currentCount=Replicating directory entry: %S
|
||||
# LOCALIZATION NOTE
|
||||
# do not localize %S. %S is the current address book name
|
||||
replicatingTitle=Replicating %S
|
||||
replicationOfSameInProgress=A replication of this directory is already in progress.
|
||||
replicationOfOtherInProgress=A replication of another directory is already in progress. You can only replicate one directory at a time.
|
||||
mustBeOnlineToReplicate=You must be online to replicate a directory.
|
||||
# LOCALIZATION NOTE
|
||||
# do not localize %S. %S is the product name.
|
||||
replicationInProgress=%S is currently in the process of replicating an address book. Would you like to wait until the process has completed before quitting or quit now?
|
||||
waitButton=Wait
|
||||
quitButton=Quit
|
||||
|
||||
downloadButton=Download Now
|
||||
downloadButtonAccessKey=D
|
||||
cancelDownloadButton=Cancel Download
|
||||
cancelDownloadButtonAccessKey=C
|
||||
|
@ -2,6 +2,14 @@
|
||||
var gPrefInt = null;
|
||||
var gCurrentDirectory = null;
|
||||
var gCurrentDirectoryString = null;
|
||||
var gReplicationBundle = null;
|
||||
var gReplicationService =
|
||||
Components.classes["@mozilla.org/addressbook/ldap-replication-service;1"].
|
||||
getService(Components.interfaces.nsIAbLDAPReplicationService);
|
||||
var gReplicationCancelled = false;
|
||||
var gProgressText;
|
||||
var gProgressMeter;
|
||||
var gDownloadInProgress = false;
|
||||
|
||||
const kDefaultMaxHits = 100;
|
||||
const kDefaultLDAPPort = 389;
|
||||
@ -21,6 +29,12 @@ function Startup()
|
||||
{
|
||||
gPrefInt = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
gReplicationBundle = document.getElementById("bundle_replication");
|
||||
|
||||
document.getElementById("download").label =
|
||||
gReplicationBundle.getString("downloadButton");
|
||||
document.getElementById("download").accessKey =
|
||||
gReplicationBundle.getString("downloadButtonAccessKey");
|
||||
|
||||
if ( "arguments" in window && window.arguments[0] ) {
|
||||
gCurrentDirectory = window.arguments[0].selectedDirectory;
|
||||
@ -66,12 +80,97 @@ function onUnload()
|
||||
}
|
||||
}
|
||||
|
||||
var progressListener = {
|
||||
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
|
||||
{
|
||||
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_START) {
|
||||
// start the spinning
|
||||
gProgressMeter.setAttribute("mode", "undetermined");
|
||||
gProgressText.value = gReplicationBundle.getString(aStatus ?
|
||||
"replicationStarted" :
|
||||
"changesStarted");
|
||||
gDownloadInProgress = true;
|
||||
document.getElementById("download").label =
|
||||
gReplicationBundle.getString("cancelDownloadButton");
|
||||
document.getElementById("download").accessKey =
|
||||
gReplicationBundle.getString("cancelDownloadButtonAccessKey");
|
||||
}
|
||||
|
||||
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) {
|
||||
EndDownload(aStatus);
|
||||
}
|
||||
},
|
||||
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
|
||||
{
|
||||
gProgressText.value = gReplicationBundle.getFormattedString("currentCount",
|
||||
[aCurSelfProgress]);
|
||||
},
|
||||
onLocationChange: function(aWebProgress, aRequest, aLocation)
|
||||
{
|
||||
},
|
||||
onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
|
||||
{
|
||||
},
|
||||
onSecurityChange: function(aWebProgress, aRequest, state)
|
||||
{
|
||||
},
|
||||
QueryInterface : function(iid)
|
||||
{
|
||||
if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||
iid.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
function DownloadNow()
|
||||
{
|
||||
var args = {dirName: gCurrentDirectory, prefName: gCurrentDirectoryString};
|
||||
if (!gDownloadInProgress) {
|
||||
gProgressText = document.getElementById("replicationProgressText");
|
||||
gProgressMeter = document.getElementById("replicationProgressMeter");
|
||||
|
||||
window.opener.openDialog("chrome://messenger/content/addressbook/replicationProgress.xul", "", "chrome,resizable,status,centerscreen,dialog=no", args);
|
||||
gProgressText.hidden = false;
|
||||
gProgressMeter.hidden = false;
|
||||
gReplicationCancelled = false;
|
||||
|
||||
try {
|
||||
gReplicationService.startReplication(gCurrentDirectoryString,
|
||||
progressListener);
|
||||
}
|
||||
catch (ex) {
|
||||
EndDownload(false);
|
||||
}
|
||||
} else {
|
||||
gReplicationCancelled = true;
|
||||
try {
|
||||
gReplicationService.cancelReplication(gCurrentDirectoryString);
|
||||
}
|
||||
catch (ex) {
|
||||
// XXX todo
|
||||
// perhaps replication hasn't started yet? This can happen if you hit cancel after attempting to replication when offline
|
||||
dump("unexpected failure while cancelling. ex=" + ex + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function EndDownload(aStatus)
|
||||
{
|
||||
document.getElementById("download").label =
|
||||
gReplicationBundle.getString("downloadButton");
|
||||
document.getElementById("download").accessKey =
|
||||
gReplicationBundle.getString("downloadButtonAccessKey");
|
||||
|
||||
// stop the spinning
|
||||
gProgressMeter.setAttribute("mode", "normal");
|
||||
gProgressMeter.setAttribute("value", "100");
|
||||
gProgressMeter.hidden = true;
|
||||
|
||||
gDownloadInProgress = false;
|
||||
gProgressText.value =
|
||||
gReplicationBundle.getString(aStatus ? "replicationSucceeded" :
|
||||
gReplicationCancelled ? "replicationCancelled" :
|
||||
"replicationFailed");
|
||||
}
|
||||
|
||||
// fill the settings panel with the data from the preferences.
|
||||
|
@ -57,6 +57,7 @@
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/pref-directory-add.js"/>
|
||||
<script type="application/x-javascript" src="chrome://help/content/contextHelp.js"/>
|
||||
<stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
|
||||
<stringbundle id="bundle_replication" src="chrome://messenger/locale/addressbook/replicationProgress.properties"/>
|
||||
|
||||
<keyset id="keyset"/>
|
||||
<vbox id="editDirectory">
|
||||
@ -125,12 +126,13 @@
|
||||
<description>&offlineText.label;</description>
|
||||
<separator/>
|
||||
<hbox>
|
||||
<button id="download" label="&downloadNowButton.label;"
|
||||
accesskey="&downloadNowButton.accesskey;"
|
||||
oncommand="DownloadNow();"/>
|
||||
<button id="download" oncommand="DownloadNow();"/>
|
||||
<spacer flex="1"/>
|
||||
</hbox>
|
||||
<description id="downloadWarningMsg" hidden="true" class="error"/>
|
||||
<description id="replicationProgressText" hidden="true"/>
|
||||
|
||||
<progressmeter id="replicationProgressMeter" mode="normal" value="0" hidden="true"/>
|
||||
</vbox>
|
||||
<grid>
|
||||
<columns>
|
||||
|
@ -68,8 +68,6 @@
|
||||
<!ENTITY return.accesskey "r">
|
||||
<!ENTITY results.label "results">
|
||||
<!ENTITY offlineText.label "You can download a local copy of this directory so that it is available for use when you are working offline.">
|
||||
<!ENTITY downloadNowButton.label "Download Now">
|
||||
<!ENTITY downloadNowButton.accesskey "D">
|
||||
<!-- Localization note: this is here because the width of the dialog
|
||||
is determined by the width of the base DN box; and that is likely
|
||||
to vary somewhat with the language.
|
||||
|
@ -21,6 +21,7 @@
|
||||
#Contributor(s):
|
||||
# Rajiv Dayal <rdayal@netscape.com>
|
||||
# Seth Spitzer <sspitzer@netscape.com>
|
||||
# Mark Banner <bugzilla@standard8.demon.co.uk>
|
||||
#
|
||||
#Alternatively, the contents of this file may be used under the terms of
|
||||
#either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -39,17 +40,12 @@ replicationStarted=Replication started...
|
||||
changesStarted=Started finding changes to replicate...
|
||||
replicationSucceeded=Replication succeeded
|
||||
replicationFailed=Replication failed
|
||||
replicationCancelled=Replication cancelled
|
||||
# LOCALIZATION NOTE
|
||||
# do not localize %S. %S is the current entry number (an integer)
|
||||
currentCount=Replicating directory entry: %S
|
||||
# LOCALIZATION NOTE
|
||||
# do not localize %S. %S is the current address book name
|
||||
replicatingTitle=Replicating %S
|
||||
replicationOfSameInProgress=A replication of this directory is already in progress.
|
||||
replicationOfOtherInProgress=A replication of another directory is already in progress. You can only replicate one directory at a time.
|
||||
mustBeOnlineToReplicate=You must be online to replicate a directory.
|
||||
# LOCALIZATION NOTE
|
||||
# do not localize %S. %S is the product name.
|
||||
replicationInProgress=%S is currently in the process of replicating an address book. Would you like to wait until the process has completed before quitting or quit now?
|
||||
waitButton=Wait
|
||||
quitButton=Quit
|
||||
|
||||
downloadButton=Download Now
|
||||
downloadButtonAccessKey=D
|
||||
cancelDownloadButton=Cancel Download
|
||||
cancelDownloadButtonAccessKey=C
|
||||
|
Loading…
Reference in New Issue
Block a user