Display "Load WebDAV URL" button in Verify Server error

Allows for easier Standalone cert override (I hope -- not yet tested)
This commit is contained in:
Dan Stillman 2011-12-17 16:13:37 -05:00
parent 0456e5d3be
commit fe97d33e38
3 changed files with 90 additions and 15 deletions

View File

@ -1095,11 +1095,7 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.checkServerCallback = function (uri
// If there's an error, just display that
if (e) {
promptService.alert(
window,
Zotero.getString('general.error'),
e.toString()
);
Zotero.Utilities.Internal.errorPrompt(Zotero.getString('general.error'), e);
return false;
}
@ -1645,9 +1641,11 @@ Zotero.Sync.Storage.Session.WebDAV.prototype._checkResponse = function (req, obj
if (!channel instanceof Ci.nsIChannel) {
obj.onError('No HTTPS channel available');
}
var secInfo = channel.securityInfo;
if (secInfo instanceof Ci.nsITransportSecurityInfo) {
secInfo.QueryInterface(Ci.nsITransportSecurityInfo);
if ((secInfo.securityState & Ci.nsIWebProgressListener.STATE_IS_INSECURE) == Ci.nsIWebProgressListener.STATE_IS_INSECURE) {
var host = 'host';
try {
@ -1657,20 +1655,40 @@ Zotero.Sync.Storage.Session.WebDAV.prototype._checkResponse = function (req, obj
Zotero.debug(e);
}
var msg = Zotero.localeJoin([
Zotero.getString('sync.storage.error.webdav.sslCertificateError', host),
Zotero.getString('sync.storage.error.webdav.loadURLForMoreInfo')
]);
var msg = Zotero.getString('sync.storage.error.webdav.sslCertificateError', host)
+ " " + Zotero.getString('sync.storage.error.webdav.loadURLForMoreInfo');
var e = new Zotero.Error(
msg,
0,
{
dialogText: msg,
dialogButtonText: Zotero.getString('sync.storage.error.webdav.loadURL'),
dialogButtonCallback: function () {
var zp = Zotero.getActiveZoteroPane();
zp.loadURI(channel.URI.spec, { shiftKey: true });
}
}
);
obj.onError(msg);
obj.onError(e);
return;
}
else if ((secInfo.securityState & Ci.nsIWebProgressListener.STATE_IS_BROKEN) == Ci.nsIWebProgressListener.STATE_IS_BROKEN) {
var msg = Zotero.localeJoin([
Zotero.getString('sync.storage.error.webdav.sslConnectionError', host),
Zotero.getString('sync.storage.error.webdav.loadURLForMoreInfo')
]);
obj.onError(msg);
var msg = Zotero.getString('sync.storage.error.webdav.sslConnectionError', host) +
Zotero.getString('sync.storage.error.webdav.loadURLForMoreInfo');
var e = new Zotero.Error(
msg,
0,
{
dialogText: msg,
dialogButtonText: Zotero.getString('sync.storage.error.webdav.loadURL'),
dialogButtonCallback: function () {
var zp = Zotero.getActiveZoteroPane();
zp.loadURI(channel.URI.spec, { shiftKey: true });
}
}
);
obj.onError(e);
return;
}
}

View File

@ -102,6 +102,62 @@ Zotero.Utilities.Internal = {
ascii.push(String.fromCharCode(tens + (tens > 9 ? 87 : 48)) + String.fromCharCode(ones + (ones > 9 ? 87 : 48)));
}
return ascii.join('');
},
/**
* Display a prompt from an error with custom buttons and a callback
*/
"errorPrompt":function(title, e) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var message, buttonText, buttonCallback;
if (e.data) {
if (e.data.dialogText) {
message = e.data.dialogText;
}
if (typeof e.data.dialogButtonText != 'undefined') {
buttonText = e.data.dialogButtonText;
buttonCallback = e.data.dialogButtonCallback;
}
}
if (!message) {
if (e.message) {
message = e.message;
}
else {
message = e;
}
}
if (typeof buttonText == 'undefined') {
buttonText = Zotero.getString('errorReport.reportError');
buttonCallback = function () {
win.ZoteroPane.reportErrors();
}
}
// If secondary button is explicitly null, just use an alert
else if (buttonText === null) {
ps.alert(null, title, message);
return;
}
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_OK
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
var index = ps.confirmEx(
null,
title,
message,
buttonFlags,
"",
buttonText,
"", null, {}
);
if (index == 1) {
setTimeout(function () { buttonCallback(); }, 1);
}
}
}

View File

@ -681,6 +681,7 @@ sync.storage.error.webdav.insufficientSpace = A file upload failed due to insuf
sync.storage.error.webdav.sslCertificateError = SSL certificate error connecting to %S.
sync.storage.error.webdav.sslConnectionError = SSL connection error connecting to %S.
sync.storage.error.webdav.loadURLForMoreInfo = Load your WebDAV URL in the browser for more information.
sync.storage.error.webdav.loadURL = Load WebDAV URL
sync.storage.error.zfs.personalQuotaReached1 = You have reached your Zotero File Storage quota. Some files were not uploaded. Other Zotero data will continue to sync to the server.
sync.storage.error.zfs.personalQuotaReached2 = See your zotero.org account settings for additional storage options.
sync.storage.error.zfs.groupQuotaReached1 = The group '%S' has reached its Zotero File Storage quota. Some files were not uploaded. Other Zotero data will continue to sync to the server.