summaryrefslogtreecommitdiffstats
path: root/services/sync
diff options
context:
space:
mode:
Diffstat (limited to 'services/sync')
-rw-r--r--services/sync/SyncComponents.manifest5
-rw-r--r--services/sync/Weave.js6
-rw-r--r--services/sync/locales/en-US/errors.properties2
-rw-r--r--services/sync/locales/en-US/sync.properties27
-rw-r--r--services/sync/modules/main.js1
-rw-r--r--services/sync/modules/notifications.js131
-rw-r--r--services/sync/modules/record.js4
-rw-r--r--services/sync/modules/service.js49
-rw-r--r--services/sync/moz.build8
-rw-r--r--services/sync/services-sync.js1
-rw-r--r--services/sync/tests/unit/test_service_login.js2
-rw-r--r--services/sync/tests/unit/test_syncscheduler.js2
-rw-r--r--services/sync/tests/unit/xpcshell.ini1
-rw-r--r--services/sync/tps/extensions/mozmill/resource/driver/controller.js2
-rw-r--r--services/sync/tps/extensions/mozmill/resource/modules/assertions.js2
15 files changed, 204 insertions, 39 deletions
diff --git a/services/sync/SyncComponents.manifest b/services/sync/SyncComponents.manifest
index 6493bb224..c58286277 100644
--- a/services/sync/SyncComponents.manifest
+++ b/services/sync/SyncComponents.manifest
@@ -3,7 +3,8 @@
# Thus we restrict it to these apps:
#
# b2g: {3c2e2abc-06d4-11e1-ac3b-374f68613e61}
-# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+# basilisk: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+# pale moon: {8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
# suite (comm): {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}
@@ -12,7 +13,7 @@
# Weave.js
component {74b89fb0-f200-4ae8-a3ec-dd164117f6de} Weave.js
contract @mozilla.org/weave/service;1 {74b89fb0-f200-4ae8-a3ec-dd164117f6de}
-category app-startup WeaveService service,@mozilla.org/weave/service;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66} application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} application={99bceaaa-e3c6-48c1-b981-ef9b46b67d60} application={d1bfe7d9-c01e-4237-998b-7b5f960a4314}
+category app-startup WeaveService service,@mozilla.org/weave/service;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66} application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} application={99bceaaa-e3c6-48c1-b981-ef9b46b67d60} application={d1bfe7d9-c01e-4237-998b-7b5f960a4314}
component {d28f8a0b-95da-48f4-b712-caf37097be41} Weave.js
contract @mozilla.org/network/protocol/about;1?what=sync-log {d28f8a0b-95da-48f4-b712-caf37097be41}
diff --git a/services/sync/Weave.js b/services/sync/Weave.js
index 4d79144e3..a414fa083 100644
--- a/services/sync/Weave.js
+++ b/services/sync/Weave.js
@@ -72,10 +72,12 @@ WeaveService.prototype = {
Ci.nsISupportsWeakReference]),
ensureLoaded: function () {
+#ifndef MC_PALEMOON
// If we are loaded and not using FxA, load the migration module.
if (!this.fxAccountsEnabled) {
Cu.import("resource://services-sync/FxaMigrator.jsm");
}
+#endif
Components.utils.import("resource://services-sync/main.js");
@@ -103,6 +105,9 @@ WeaveService.prototype = {
* @return bool
*/
get fxAccountsEnabled() {
+#ifdef MC_PALEMOON
+ return false;
+#else
try {
// Old sync guarantees '@' will never appear in the username while FxA
// uses the FxA email address - so '@' is the flag we use.
@@ -111,6 +116,7 @@ WeaveService.prototype = {
} catch (_) {
return true; // No username == only allow FxA to be configured.
}
+#endif
},
/**
diff --git a/services/sync/locales/en-US/errors.properties b/services/sync/locales/en-US/errors.properties
index 3dfa074bc..f67f5ea1c 100644
--- a/services/sync/locales/en-US/errors.properties
+++ b/services/sync/locales/en-US/errors.properties
@@ -12,7 +12,7 @@ error.login.reason.server = Server incorrectly configured
error.sync.failed_partial = One or more data types could not be synced
# LOCALIZATION NOTE (error.sync.reason.serverMaintenance): We removed the extraneous period from this string
-error.sync.reason.serverMaintenance = Firefox Sync server maintenance is underway, syncing will resume automatically
+error.sync.reason.serverMaintenance = Sync server maintenance is underway, syncing will resume automatically
invalid-captcha = Incorrect words, try again
weak-password = Use a stronger password
diff --git a/services/sync/locales/en-US/sync.properties b/services/sync/locales/en-US/sync.properties
index d00183118..a1a6f76b2 100644
--- a/services/sync/locales/en-US/sync.properties
+++ b/services/sync/locales/en-US/sync.properties
@@ -12,14 +12,33 @@ lastSync2.label = Last sync: %S
# not configured.
signInToSync.description = Sign In To Sync
+error.login.title = Error While Signing In
+error.login.description = Sync encountered an error while connecting: %1$S. Please try again.
+error.login.prefs.label = Preferences…
+error.login.prefs.accesskey = P
+# should decide if we're going to show this
+error.logout.title = Error While Signing Out
+error.logout.description = Sync encountered an error while connecting. It's probably ok, and you don't have to do anything about it.
error.sync.title = Error While Syncing
error.sync.description = Sync encountered an error while syncing: %1$S. Sync will automatically retry this action.
+error.sync.prolonged_failure = Sync has not been able to complete during the last %1$S days. Please check your network settings.
+error.sync.serverStatusButton.label = Server Status
+error.sync.serverStatusButton.accesskey = V
+error.sync.needUpdate.description = You need to update Sync to continue syncing your data.
+error.sync.needUpdate.label = Update Sync
+error.sync.needUpdate.accesskey = U
+error.sync.tryAgainButton.label = Sync Now
+error.sync.tryAgainButton.accesskey = S
+warning.sync.quota.label = Approaching Server Quota
+warning.sync.quota.description = You are approaching the server quota. Please review which data to sync.
+error.sync.viewQuotaButton.label = View Quota
+error.sync.viewQuotaButton.accesskey = V
warning.sync.eol.label = Service Shutting Down
-# %1: the app name (Firefox)
-warning.sync.eol.description = Your Firefox Sync service is shutting down soon. Upgrade %1$S to keep syncing.
+# %1: the app name (Basilisk)
+warning.sync.eol.description = Your Sync service is shutting down soon. Upgrade %1$S to keep syncing.
error.sync.eol.label = Service Unavailable
-# %1: the app name (Firefox)
-error.sync.eol.description = Your Firefox Sync service is no longer available. You need to upgrade %1$S to keep syncing.
+# %1: the app name (Basilisk)
+error.sync.eol.description = Your Sync service is no longer available. You need to upgrade %1$S to keep syncing.
sync.eol.learnMore.label = Learn more
sync.eol.learnMore.accesskey = L
diff --git a/services/sync/modules/main.js b/services/sync/modules/main.js
index af3399e7a..e8e705e72 100644
--- a/services/sync/modules/main.js
+++ b/services/sync/modules/main.js
@@ -8,6 +8,7 @@ this.Weave = {};
Components.utils.import("resource://services-sync/constants.js", Weave);
var lazies = {
"jpakeclient.js": ["JPAKEClient", "SendCredentialsController"],
+ "notifications.js": ["Notifications", "Notification", "NotificationButton"],
"service.js": ["Service"],
"status.js": ["Status"],
"util.js": ['Utils', 'Svc']
diff --git a/services/sync/modules/notifications.js b/services/sync/modules/notifications.js
new file mode 100644
index 000000000..72187a4ce
--- /dev/null
+++ b/services/sync/modules/notifications.js
@@ -0,0 +1,131 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+this.EXPORTED_SYMBOLS = ["Notifications", "Notification", "NotificationButton"];
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cr = Components.results;
+var Cu = Components.utils;
+
+Cu.import("resource://services-common/observers.js");
+Cu.import("resource://gre/modules/Log.jsm");
+Cu.import("resource://services-sync/util.js");
+
+this.Notifications = {
+ // Match the referenced values in toolkit/content/widgets/notification.xml.
+ get PRIORITY_INFO() { return 1; }, // PRIORITY_INFO_LOW
+ get PRIORITY_WARNING() { return 4; }, // PRIORITY_WARNING_LOW
+ get PRIORITY_ERROR() { return 7; }, // PRIORITY_CRITICAL_LOW
+
+ // FIXME: instead of making this public, dress the Notifications object
+ // to behave like an iterator (using generators?) and have callers access
+ // this array through the Notifications object.
+ notifications: [],
+
+ _observers: [],
+
+ // XXX Should we have a helper method for adding a simple notification?
+ // I.e. something like |function notify(title, description, priority)|.
+
+ add: function Notifications_add(notification) {
+ this.notifications.push(notification);
+ Observers.notify("weave:notification:added", notification, null);
+ },
+
+ remove: function Notifications_remove(notification) {
+ let index = this.notifications.indexOf(notification);
+
+ if (index != -1) {
+ this.notifications.splice(index, 1);
+ Observers.notify("weave:notification:removed", notification, null);
+ }
+ },
+
+ /**
+ * Replace an existing notification.
+ */
+ replace: function Notifications_replace(oldNotification, newNotification) {
+ let index = this.notifications.indexOf(oldNotification);
+
+ if (index != -1)
+ this.notifications.splice(index, 1, newNotification);
+ else {
+ this.notifications.push(newNotification);
+ // XXX Should we throw because we didn't find the existing notification?
+ // XXX Should we notify observers about weave:notification:added?
+ }
+
+ // XXX Should we notify observers about weave:notification:replaced?
+ },
+
+ /**
+ * Remove all notifications that match a title. If no title is provided, all
+ * notifications are removed.
+ *
+ * @param title [optional]
+ * Title of notifications to remove; falsy value means remove all
+ */
+ removeAll: function Notifications_removeAll(title) {
+ this.notifications.filter(old => (old.title == title || !title)).
+ forEach(old => { this.remove(old); }, this);
+ },
+
+ // replaces all existing notifications with the same title as the new one
+ replaceTitle: function Notifications_replaceTitle(notification) {
+ this.removeAll(notification.title);
+ this.add(notification);
+ }
+};
+
+
+/**
+ * A basic notification. Subclass this to create more complex notifications.
+ */
+this.Notification =
+function Notification(title, description, iconURL, priority, buttons, link) {
+ this.title = title;
+ this.description = description;
+
+ if (iconURL)
+ this.iconURL = iconURL;
+
+ if (priority)
+ this.priority = priority;
+
+ if (buttons)
+ this.buttons = buttons;
+
+ if (link)
+ this.link = link;
+}
+
+// We set each prototype property individually instead of redefining
+// the entire prototype to avoid blowing away existing properties
+// of the prototype like the the "constructor" property, which we use
+// to bind notification objects to their XBL representations.
+Notification.prototype.priority = Notifications.PRIORITY_INFO;
+Notification.prototype.iconURL = null;
+Notification.prototype.buttons = [];
+
+/**
+ * A button to display in a notification.
+ */
+this.NotificationButton =
+ function NotificationButton(label, accessKey, callback) {
+ function callbackWrapper() {
+ try {
+ callback.apply(this, arguments);
+ } catch (e) {
+ let logger = Log.repository.getLogger("Sync.Notifications");
+ logger.error("An exception occurred: " + Utils.exceptionStr(e));
+ logger.info(Utils.stackTrace(e));
+ throw e;
+ }
+ }
+
+ this.label = label;
+ this.accessKey = accessKey;
+ this.callback = callbackWrapper;
+}
diff --git a/services/sync/modules/record.js b/services/sync/modules/record.js
index 02f7f281a..f7a69d9ef 100644
--- a/services/sync/modules/record.js
+++ b/services/sync/modules/record.js
@@ -43,7 +43,7 @@ WBORecord.prototype = {
// Get thyself from your URI, then deserialize.
// Set thine 'response' field.
fetch: function fetch(resource) {
- if (!resource instanceof Resource) {
+ if (!(resource instanceof Resource)) {
throw new Error("First argument must be a Resource instance.");
}
@@ -56,7 +56,7 @@ WBORecord.prototype = {
},
upload: function upload(resource) {
- if (!resource instanceof Resource) {
+ if (!(resource instanceof Resource)) {
throw new Error("First argument must be a Resource instance.");
}
diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js
index b0eb0f41d..f8c64b0fa 100644
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -455,7 +455,7 @@ Sync11Service.prototype = {
this.clientsEngine = new ClientEngine(this);
for (let name of engines) {
- if (!name in ENGINE_MODULES) {
+ if (!(name in ENGINE_MODULES)) {
this._log.info("Do not know about engine: " + name);
continue;
}
@@ -1067,31 +1067,34 @@ Sync11Service.prototype = {
// Note: returns false if we failed for a reason other than the server not yet
// supporting the api.
_fetchServerConfiguration() {
- // This is similar to _fetchInfo, but with different error handling.
+ if (Svc.Prefs.get("APILevel") >= 2) {
+ // This is similar to _fetchInfo, but with different error handling.
+ // Only supported by later sync implementations.
- let infoURL = this.userBaseURL + "info/configuration";
- this._log.debug("Fetching server configuration", infoURL);
- let configResponse;
- try {
- configResponse = this.resource(infoURL).get();
- } catch (ex) {
- // This is probably a network or similar error.
- this._log.warn("Failed to fetch info/configuration", ex);
- this.errorHandler.checkServerError(ex);
- return false;
- }
+ let infoURL = this.userBaseURL + "info/configuration";
+ this._log.debug("Fetching server configuration", infoURL);
+ let configResponse;
+ try {
+ configResponse = this.resource(infoURL).get();
+ } catch (ex) {
+ // This is probably a network or similar error.
+ this._log.warn("Failed to fetch info/configuration", ex);
+ this.errorHandler.checkServerError(ex);
+ return false;
+ }
- if (configResponse.status == 404) {
- // This server doesn't support the URL yet - that's OK.
- this._log.debug("info/configuration returned 404 - using default upload semantics");
- } else if (configResponse.status != 200) {
- this._log.warn(`info/configuration returned ${configResponse.status} - using default configuration`);
- this.errorHandler.checkServerError(configResponse);
- return false;
- } else {
- this.serverConfiguration = configResponse.obj;
+ if (configResponse.status == 404) {
+ // This server doesn't support the URL yet - that's OK.
+ this._log.debug("info/configuration returned 404 - using default upload semantics");
+ } else if (configResponse.status != 200) {
+ this._log.warn(`info/configuration returned ${configResponse.status} - using default configuration`);
+ this.errorHandler.checkServerError(configResponse);
+ return false;
+ } else {
+ this.serverConfiguration = configResponse.obj;
+ }
+ this._log.trace("info/configuration for this server", this.serverConfiguration);
}
- this._log.trace("info/configuration for this server", this.serverConfiguration);
return true;
},
diff --git a/services/sync/moz.build b/services/sync/moz.build
index c4d3607b5..83c39274a 100644
--- a/services/sync/moz.build
+++ b/services/sync/moz.build
@@ -13,6 +13,9 @@ XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
EXTRA_COMPONENTS += [
'SyncComponents.manifest',
+]
+
+EXTRA_PP_COMPONENTS += [
'Weave.js',
]
@@ -28,11 +31,11 @@ EXTRA_JS_MODULES['services-sync'] += [
'modules/jpakeclient.js',
'modules/keys.js',
'modules/main.js',
+ 'modules/notifications.js',
'modules/policies.js',
'modules/record.js',
'modules/resource.js',
'modules/rest.js',
- 'modules/service.js',
'modules/status.js',
'modules/SyncedTabs.jsm',
'modules/telemetry.js',
@@ -42,10 +45,11 @@ EXTRA_JS_MODULES['services-sync'] += [
EXTRA_PP_JS_MODULES['services-sync'] += [
'modules/constants.js',
+ 'modules/service.js',
]
# Definitions used by constants.js
-DEFINES['weave_version'] = '1.54.0'
+DEFINES['weave_version'] = '1.54.1'
DEFINES['weave_id'] = '{340c2bbc-ce74-4362-90b5-7c26312808ef}'
EXTRA_JS_MODULES['services-sync'].engines += [
diff --git a/services/sync/services-sync.js b/services/sync/services-sync.js
index f4167c1ce..ebac4412b 100644
--- a/services/sync/services-sync.js
+++ b/services/sync/services-sync.js
@@ -12,6 +12,7 @@ pref("services.sync.syncKeyHelpURL", "https://services.mozilla.com/help/synckey"
pref("services.sync.lastversion", "firstrun");
pref("services.sync.sendVersionInfo", true);
+pref("services.sync.APILevel", 2);
pref("services.sync.scheduler.eolInterval", 604800); // 1 week
pref("services.sync.scheduler.idleInterval", 3600); // 1 hour
diff --git a/services/sync/tests/unit/test_service_login.js b/services/sync/tests/unit/test_service_login.js
index 42c163915..2ecb0a377 100644
--- a/services/sync/tests/unit/test_service_login.js
+++ b/services/sync/tests/unit/test_service_login.js
@@ -206,7 +206,7 @@ add_test(function test_login_on_sync() {
_("Old passphrase function is " + oldGetter);
Service.identity.__defineGetter__("syncKey",
function() {
- throw "User canceled Master Password entry";
+ throw "User canceled master password entry";
});
let oldClearSyncTriggers = Service.scheduler.clearSyncTriggers;
diff --git a/services/sync/tests/unit/test_syncscheduler.js b/services/sync/tests/unit/test_syncscheduler.js
index b066eae82..730a3f996 100644
--- a/services/sync/tests/unit/test_syncscheduler.js
+++ b/services/sync/tests/unit/test_syncscheduler.js
@@ -535,7 +535,7 @@ add_task(function* test_autoconnect_mp_locked() {
delete Service.identity.syncKey;
Service.identity.__defineGetter__("syncKey", function() {
_("Faking Master Password entry cancelation.");
- throw "User canceled Master Password entry";
+ throw "User canceled master password entry";
});
let deferred = Promise.defer();
diff --git a/services/sync/tests/unit/xpcshell.ini b/services/sync/tests/unit/xpcshell.ini
index 5a90652b8..609003ce9 100644
--- a/services/sync/tests/unit/xpcshell.ini
+++ b/services/sync/tests/unit/xpcshell.ini
@@ -13,7 +13,6 @@ support-files =
sync_ping_schema.json
systemaddon-search.xml
!/services/common/tests/unit/head_helpers.js
- !/toolkit/mozapps/webextensions/test/xpcshell/head_addons.js
!/toolkit/components/webextensions/test/xpcshell/head_sync.js
# The manifest is roughly ordered from low-level to high-level. When making
diff --git a/services/sync/tps/extensions/mozmill/resource/driver/controller.js b/services/sync/tps/extensions/mozmill/resource/driver/controller.js
index a378ce51f..8d66a41ae 100644
--- a/services/sync/tps/extensions/mozmill/resource/driver/controller.js
+++ b/services/sync/tps/extensions/mozmill/resource/driver/controller.js
@@ -978,7 +978,7 @@ function browserAdditions (controller) {
}, "Timeout", timeout, aInterval);
}
catch (ex) {
- if (!ex instanceof errors.TimeoutError) {
+ if (!(ex instanceof errors.TimeoutError)) {
throw ex;
}
timed_out = true;
diff --git a/services/sync/tps/extensions/mozmill/resource/modules/assertions.js b/services/sync/tps/extensions/mozmill/resource/modules/assertions.js
index c9991acf0..c76f95747 100644
--- a/services/sync/tps/extensions/mozmill/resource/modules/assertions.js
+++ b/services/sync/tps/extensions/mozmill/resource/modules/assertions.js
@@ -659,7 +659,7 @@ Expect.prototype.waitFor = function Expect_waitFor(aCallback, aMessage, aTimeout
Assert.prototype.waitFor.apply(this, arguments);
}
catch (ex) {
- if (!ex instanceof errors.AssertionError) {
+ if (!(ex instanceof errors.AssertionError)) {
throw ex;
}
message = ex.message;