Bug 340560 Integrate the replication progress dialog into the LDAP directory properties window. r=Neil,sr=bienvenu

This commit is contained in:
bugzilla%standard8.demon.co.uk 2006-06-12 16:52:40 +00:00
Родитель 64c6b7d859
Коммит e39e6197d9
6 изменённых файлов: 119 добавлений и 106 удалений

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

@ -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>

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

@ -1,77 +0,0 @@
<!-- ***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is
Netscape Communications Corporation.
Portions created by the Initial Developer are Copyright (C) 1998-2002
the Initial Developer. All Rights Reserved.
Contributor(s):
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"),
or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK ***** -->
<!ENTITY newDirectoryTitle.label "Directory Server Properties">
<!ENTITY directoryName.label "Name: ">
<!ENTITY directoryName.accesskey "n">
<!ENTITY directoryHostname.label "Hostname: ">
<!ENTITY directoryHostname.accesskey "o">
<!ENTITY directoryBaseDN.label "Base DN: ">
<!ENTITY directoryBaseDN.accesskey "b">
<!ENTITY findButton.label "Find">
<!ENTITY findButton.accesskey "f">
<!ENTITY directorySecure.label "Use secure connection (SSL)">
<!ENTITY directorySecure.accesskey "U">
<!ENTITY directoryLogin.label "Bind DN: ">
<!ENTITY directoryLogin.accesskey "i">
<!ENTITY advancedOptionsButton.label "Advanced Options">
<!ENTITY advancedOptionsButton.accesskey "a">
<!ENTITY General.tab "General">
<!ENTITY Offline.tab "Offline">
<!ENTITY Advanced.tab "Advanced">
<!ENTITY advancedOptionsTitle.label "Advanced Options">
<!ENTITY portNumber.label "Port number: ">
<!ENTITY portNumber.accesskey "p">
<!ENTITY searchFilter.label "Search filter: ">
<!ENTITY searchFilter.accesskey "f">
<!ENTITY scope.label "Scope: ">
<!ENTITY scope.accesskey "c">
<!ENTITY scopeOneLevel.label "One Level">
<!ENTITY scopeOneLevel.accesskey "L">
<!ENTITY scopeSubtree.label "Subtree">
<!ENTITY scopeSubtree.accesskey "S">
<!ENTITY return.label "Don't return more than">
<!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.
-->
<!ENTITY newDirectoryWidth "36em">

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

@ -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