Fix bug 456208 - Disabling calendars autorefresh does not prevent cached calendar sync. r=nomisvai
--HG-- extra : rebase_source : ba9126e7e371d70480597d1bd625cfe2b3fbec35
This commit is contained in:
Родитель
19197f70c1
Коммит
774a69a84a
|
@ -37,6 +37,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
Components.utils.import("resource://calendar/modules/calUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
/**
|
||||
* The calendar to modify, is retrieved from window.arguments[0].calendar
|
||||
|
@ -59,8 +60,10 @@ function onLoad() {
|
|||
document.getElementById("calendar-uri").value = gCalendar.uri.spec;
|
||||
document.getElementById("read-only").checked = gCalendar.readOnly;
|
||||
|
||||
// Set up refresh interval
|
||||
initRefreshInterval();
|
||||
|
||||
// set up the cache field
|
||||
// Set up the cache field
|
||||
var cacheBox = document.getElementById("cache");
|
||||
var canCache = (gCalendar.getProperty("cache.supported") !== false);
|
||||
if (!canCache) {
|
||||
|
@ -115,6 +118,12 @@ function onAcceptDialog() {
|
|||
// Save supressAlarms
|
||||
gCalendar.setProperty("suppressAlarms", !document.getElementById("fire-alarms").checked);
|
||||
|
||||
// Save refresh interval
|
||||
if (gCalendar.canRefresh) {
|
||||
let value = getElementValue("calendar-refreshInterval-menulist");
|
||||
gCalendar.setProperty("refreshInterval", value);
|
||||
}
|
||||
|
||||
// Save cache options
|
||||
gCalendar.setProperty("cache.enabled", document.getElementById("cache").checked);
|
||||
|
||||
|
@ -149,3 +158,48 @@ function unsubscribeCalendar() {
|
|||
calmgr.unregisterCalendar(gCalendar);
|
||||
window.close();
|
||||
}
|
||||
|
||||
function initRefreshInterval() {
|
||||
setBooleanAttribute("calendar-refreshInterval-row", "hidden", !gCalendar.canRefresh);
|
||||
|
||||
if (gCalendar.canRefresh) {
|
||||
function createMenuItem(minutes) {
|
||||
let menuitem = createXULElement("menuitem");
|
||||
menuitem.setAttribute("value", minutes);
|
||||
|
||||
let everyMinuteString = cal.calGetString("calendar", "calendarPropertiesEveryMinute");
|
||||
let label = PluralForm.get(minutes, everyMinuteString).replace("#1", minutes);
|
||||
menuitem.setAttribute("label", label);
|
||||
|
||||
return menuitem;
|
||||
}
|
||||
|
||||
let refreshInterval = gCalendar.getProperty("refreshInterval");
|
||||
if (refreshInterval === null) refreshInterval = 30;
|
||||
|
||||
let foundValue = false;
|
||||
let separator = document.getElementById("calendar-refreshInterval-manual-separator");
|
||||
let menulist = document.getElementById("calendar-refreshInterval-menulist");
|
||||
for each (let min in [1, 5, 15, 30, 60]) {
|
||||
let menuitem = createMenuItem(min);
|
||||
|
||||
separator.parentNode.insertBefore(menuitem, separator);
|
||||
if (refreshInterval == min) {
|
||||
menulist.selectedItem = menuitem;
|
||||
foundValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (refreshInterval == 0) {
|
||||
setBooleanAttribute("calendar-refreshInterval-manual", "checked", true);
|
||||
foundValue = true;
|
||||
}
|
||||
|
||||
if (!foundValue) {
|
||||
// Special menuitem in case the user changed the value in the config editor.
|
||||
let menuitem = createMenuItem(refreshInterval);
|
||||
separator.parentNode.insertBefore(menuitem, separator.nextSibling);
|
||||
menulist.selectedItem = menuitem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,6 +105,22 @@
|
|||
<!-- XXX Make location field readonly until Bug 315307 is fixed -->
|
||||
<textbox id="calendar-uri" readonly="true" disable-with-calendar="true"/>
|
||||
</row>
|
||||
<row id="calendar-refreshInterval-row" align="center">
|
||||
<label value="&calendarproperties.refreshInterval.label;"
|
||||
disable-with-calendar="true"
|
||||
control="calendar-refreshInterval-textbox"/>
|
||||
<menulist id="calendar-refreshInterval-menulist"
|
||||
disable-with-calendar="true"
|
||||
label="&calendarproperties.refreshInterval.label;">
|
||||
<menupopup id="calendar-refreshInterval-menupopup">
|
||||
<!-- This will be filled programatically to reduce the number of needed strings -->
|
||||
<menuseparator id="calendar-refreshInterval-manual-separator"/>
|
||||
<menuitem id="calendar-refreshInterval-manual"
|
||||
value="0"
|
||||
label="&calendarproperties.refreshInterval.manual.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</row>
|
||||
<row id="calendar-readOnly-row"
|
||||
align="center">
|
||||
<spacer/>
|
||||
|
|
|
@ -61,16 +61,5 @@ var gCalendarGeneralPane = {
|
|||
|
||||
// deselect and reselect to update visible item title
|
||||
updateSelectedLabel("dateformat");
|
||||
},
|
||||
|
||||
/**
|
||||
* Update disabled state of the controls that depend on the
|
||||
* calendar.autorefresh.enabled preference.
|
||||
*/
|
||||
autoRefreshPrefChanged: function gCGP_autoRefreshPrefChanged() {
|
||||
var autoRefreshPref =
|
||||
document.getElementById("calendar.autorefresh.enabled").value;
|
||||
document.getElementById("calendar.autorefresh.timeout").disabled =
|
||||
!autoRefreshPref;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -70,13 +70,6 @@
|
|||
<preference id="calendar.alarms.defaultsnoozelength"
|
||||
name="calendar.alarms.defaultsnoozelength"
|
||||
type="int"/>
|
||||
<preference id="calendar.autorefresh.enabled"
|
||||
name="calendar.autorefresh.enabled"
|
||||
type="bool"
|
||||
onchange="gCalendarGeneralPane.autoRefreshPrefChanged();"/>
|
||||
<preference id="calendar.autorefresh.timeout"
|
||||
name="calendar.autorefresh.timeout"
|
||||
type="int"/>
|
||||
</preferences>
|
||||
|
||||
<groupbox>
|
||||
|
@ -125,23 +118,5 @@
|
|||
</hbox>
|
||||
|
||||
</groupbox>
|
||||
|
||||
<groupbox>
|
||||
<caption label="&pref.refreshbox.label;"/>
|
||||
<hbox align="center">
|
||||
<checkbox id="autorefreshenabled"
|
||||
label="&pref.autorefresh.label;"
|
||||
preference="calendar.autorefresh.enabled"
|
||||
accesskey="&pref.autorefresh.accesskey;"/>
|
||||
<textbox id="refreshtimeout"
|
||||
preference="calendar.autorefresh.timeout"
|
||||
type="number"
|
||||
min="1"
|
||||
max="0x7FFFF"
|
||||
size="3"/>
|
||||
<label value="&calendar.global.units.minutes;"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
</vbox>
|
||||
</overlay>
|
||||
|
|
|
@ -111,27 +111,6 @@ function calCachedCalendar(uncachedCalendar) {
|
|||
uncachedCalendar.addObserver(new calCachedCalendarObserverHelper(this, false));
|
||||
this.mUncachedCalendar = uncachedCalendar;
|
||||
this.setupCachedCalendar();
|
||||
|
||||
if (this.supportsChangeLog) {
|
||||
var updateTimer = this.getProperty("cache.updateTimer");
|
||||
if (updateTimer === null) {
|
||||
updateTimer = 4; // override for changelog based providers
|
||||
}
|
||||
var timerCallback = {
|
||||
mCalendar: this,
|
||||
notify: function(timer) {
|
||||
LOG("[calCachedCalendar] replay timer");
|
||||
if (!this.mCalendar.getProperty("disabled")) {
|
||||
this.mCalendar.refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.mReplayTimer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(Components.interfaces.nsITimer);
|
||||
this.mReplayTimer.initWithCallback(timerCallback,
|
||||
updateTimer * 60 * 1000,
|
||||
Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
||||
}
|
||||
}
|
||||
calCachedCalendar.prototype = {
|
||||
QueryInterface: function cCC_QueryInterface(aIID) {
|
||||
|
@ -151,13 +130,8 @@ calCachedCalendar.prototype = {
|
|||
mUncachedCalendar: null,
|
||||
mObservers: null,
|
||||
mSuperCalendar: null,
|
||||
mReplayTimer: null,
|
||||
|
||||
onCalendarUnregistering: function() {
|
||||
if (this.mReplayTimer) {
|
||||
this.mReplayTimer.cancel();
|
||||
this.mReplayTimer = null;
|
||||
}
|
||||
if (this.mCachedCalendar) {
|
||||
this.mCachedCalendar.removeObserver(this.mCachedObserver);
|
||||
// Although this doesn't really follow the spec, we know the
|
||||
|
|
|
@ -71,6 +71,21 @@ function flushPrefs() {
|
|||
.savePrefFile(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback object for the refresh timer. Should be called as an object, i.e
|
||||
* let foo = new timerCallback(calendar);
|
||||
*
|
||||
* @param aCalendar The calendar to refresh on notification
|
||||
*/
|
||||
function timerCallback(aCalendar) {
|
||||
this.notify = function refreshNotify(aTimer) {
|
||||
if (!aCalendar.getProperty("disabled") && aCalendar.canRefresh) {
|
||||
aCalendar.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var gCalendarManagerAddonListener = {
|
||||
onDisabling: function(aAddon, aNeedsRestart) {
|
||||
if (!this.queryUninstallProvider(aAddon)) {
|
||||
|
@ -166,9 +181,7 @@ calCalendarManager.prototype = {
|
|||
this.checkAndMigrateDB();
|
||||
this.mCache = null;
|
||||
this.mCalObservers = null;
|
||||
this.mRefreshTimer = null;
|
||||
this.setUpPrefObservers();
|
||||
this.setUpRefreshTimer();
|
||||
this.mRefreshTimer = {};
|
||||
this.setupOfflineObservers();
|
||||
if (cal.isSunbird()) {
|
||||
this.loginMasterPassword();
|
||||
|
@ -185,7 +198,6 @@ calCalendarManager.prototype = {
|
|||
cal.removeObserver(this.mCalObservers[cal.id]);
|
||||
}
|
||||
|
||||
this.cleanupPrefObservers();
|
||||
this.cleanupOfflineObservers();
|
||||
|
||||
Services.obs.removeObserver(this, "profile-after-change");
|
||||
|
@ -195,32 +207,6 @@ calCalendarManager.prototype = {
|
|||
aCompleteListener.onResult(null, Components.results.NS_OK);
|
||||
},
|
||||
|
||||
setUpPrefObservers: function ccm_setUpPrefObservers() {
|
||||
Services.prefs.addObserver("calendar.autorefresh.enabled", this, false);
|
||||
Services.prefs.addObserver("calendar.autorefresh.timeout", this, false);
|
||||
},
|
||||
|
||||
cleanupPrefObservers: function ccm_cleanupPrefObservers() {
|
||||
Services.prefs.removeObserver("calendar.autorefresh.enabled", this);
|
||||
Services.prefs.removeObserver("calendar.autorefresh.timeout", this);
|
||||
},
|
||||
|
||||
setUpRefreshTimer: function ccm_setUpRefreshTimer() {
|
||||
if (this.mRefreshTimer) {
|
||||
this.mRefreshTimer.cancel();
|
||||
}
|
||||
|
||||
// Read and convert the minute-based pref to msecs
|
||||
let refreshEnabled = cal.getPrefSafe("calendar.autorefresh.enabled", false);
|
||||
let refreshTimeout = cal.getPrefSafe("calendar.autorefresh.timeout", 0) * 60000;
|
||||
|
||||
if (refreshEnabled && refreshTimeout > 0) {
|
||||
this.mRefreshTimer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(Components.interfaces.nsITimer);
|
||||
this.mRefreshTimer.init(this, refreshTimeout,
|
||||
Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
||||
}
|
||||
},
|
||||
|
||||
setupOfflineObservers: function ccm_setupOfflineObservers() {
|
||||
Services.obs.addObserver(this, "network:offline-status-changed", false);
|
||||
|
@ -265,12 +251,6 @@ calCalendarManager.prototype = {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case "nsPref:changed":
|
||||
if (aData == "calendar.autorefresh.enabled" ||
|
||||
aData == "calendar.autorefresh.timeout") {
|
||||
this.setUpRefreshTimer();
|
||||
}
|
||||
break;
|
||||
case "network:offline-status-changed":
|
||||
for each (var calendar in this.mCache) {
|
||||
if (calendar instanceof calCachedCalendar) {
|
||||
|
@ -401,9 +381,6 @@ calCalendarManager.prototype = {
|
|||
case "calendar-main-default":
|
||||
cal.setPref(getPrefBranchFor(id) + name, value == "true");
|
||||
break;
|
||||
case "cache.updatetimer":
|
||||
cal.setPref(getPrefBranchFor(id) + "cache.updateTimer", Number(value));
|
||||
break;
|
||||
case "backup-time":
|
||||
case "uniquenum":
|
||||
cal.setPref(getPrefBranchFor(id) + name, Number(value));
|
||||
|
@ -659,6 +636,39 @@ calCalendarManager.prototype = {
|
|||
this.mReadonlyCalendarCount++;
|
||||
}
|
||||
this.mCalendarCount++;
|
||||
|
||||
// Set up the refresh timer
|
||||
this.setupRefreshTimer(calendar);
|
||||
},
|
||||
|
||||
setupRefreshTimer: function setupRefreshTimer(aCalendar) {
|
||||
// Add the refresh timer for this calendar
|
||||
let refreshInterval = aCalendar.getProperty("refreshInterval");
|
||||
if (refreshInterval === null) {
|
||||
// Default to 30 minutes, in case the value is missing
|
||||
refreshInterval = 30;
|
||||
}
|
||||
|
||||
this.clearRefreshTimer(aCalendar);
|
||||
|
||||
if (refreshInterval > 0) {
|
||||
this.mRefreshTimer[aCalendar.id] =
|
||||
Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(Components.interfaces.nsITimer);
|
||||
|
||||
this.mRefreshTimer[aCalendar.id]
|
||||
.initWithCallback(new timerCallback(aCalendar),
|
||||
refreshInterval * 60000,
|
||||
Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
||||
}
|
||||
},
|
||||
|
||||
clearRefreshTimer: function clearRefreshTimer(aCalendar) {
|
||||
if (aCalendar.id in this.mRefreshTimer &&
|
||||
this.mRefreshTimer[aCalendar.id]) {
|
||||
this.mRefreshTimer[aCalendar.id].cancel();
|
||||
delete this.mRefreshTimer[aCalendar.id]
|
||||
}
|
||||
},
|
||||
|
||||
unregisterCalendar: function(calendar) {
|
||||
|
@ -685,6 +695,8 @@ calCalendarManager.prototype = {
|
|||
this.mNetworkCalendarCount--;
|
||||
}
|
||||
this.mCalendarCount--;
|
||||
|
||||
this.clearRefreshTimer(calendar);
|
||||
},
|
||||
|
||||
deleteCalendar: function(calendar) {
|
||||
|
@ -884,6 +896,9 @@ calMgrCalendarObserver.prototype = {
|
|||
case "readOnly":
|
||||
this.calMgr.mReadonlyCalendarCount += (aValue ? 1 : -1);
|
||||
break;
|
||||
case "refreshInterval":
|
||||
this.calMgr.setupRefreshTimer(aCalendar);
|
||||
break;
|
||||
case "cache.enabled":
|
||||
aOldValue = aOldValue || false;
|
||||
aValue = aValue || false;
|
||||
|
@ -914,6 +929,7 @@ calMgrCalendarObserver.prototype = {
|
|||
"disabled",
|
||||
"auto-enabled",
|
||||
"cache.enabled",
|
||||
"refreshInterval",
|
||||
"suppressAlarms",
|
||||
"calendar-main-in-composite",
|
||||
"calendar-main-default",
|
||||
|
|
|
@ -81,10 +81,6 @@ pref("calendar.alarms.onfortodos", 0);
|
|||
pref("calendar.alarms.todoalarmlen", 15);
|
||||
pref("calendar.alarms.todoalarmunit", "minutes");
|
||||
|
||||
// autorefresh settings
|
||||
pref("calendar.autorefresh.enabled", true);
|
||||
pref("calendar.autorefresh.timeout", 30);
|
||||
|
||||
// open invitations autorefresh settings
|
||||
pref("calendar.invitations.autorefresh.enabled", true);
|
||||
pref("calendar.invitations.autorefresh.timeout", 3);
|
||||
|
|
|
@ -321,6 +321,8 @@
|
|||
<!ENTITY calendarproperties.wcap.label "Sun Java System Calendar Server (WCAP)">
|
||||
<!ENTITY calendarproperties.format.label "Format:">
|
||||
<!ENTITY calendarproperties.location.label "Location:">
|
||||
<!ENTITY calendarproperties.refreshInterval.label "Refresh Calendar:">
|
||||
<!ENTITY calendarproperties.refreshInterval.manual.label "Manually">
|
||||
<!ENTITY calendarproperties.name.label "Name:">
|
||||
<!ENTITY calendarproperties.readonly.label "Read Only">
|
||||
<!ENTITY calendarproperties.firealarms.label "Show Alarms">
|
||||
|
|
|
@ -625,3 +625,5 @@ deleteItemAccesskey=l
|
|||
deleteEventLabel=Delete Event
|
||||
deleteEventMessage=Do you really want to delete this Event?
|
||||
deleteEventAccesskey=l
|
||||
|
||||
calendarPropertiesEveryMinute=Every minute;Every #1 minutes
|
||||
|
|
|
@ -49,6 +49,3 @@
|
|||
<!ENTITY pref.defaultlength.accesskey "E">
|
||||
<!ENTITY pref.defaultsnoozelength.label "Default Snooze Length:" >
|
||||
<!ENTITY pref.defaultsnoozelength.accesskey "S">
|
||||
<!ENTITY pref.refreshbox.label "Refresh Settings" >
|
||||
<!ENTITY pref.autorefresh.label "Refresh calendars every" >
|
||||
<!ENTITY pref.autorefresh.accesskey "R" >
|
||||
|
|
|
@ -429,8 +429,6 @@ calDavCalendar.prototype = {
|
|||
break;
|
||||
case "organizerCN":
|
||||
return null; // xxx todo
|
||||
case "cache.updateTimer":
|
||||
return getPrefSafe("calendar.autorefresh.timeout");
|
||||
case "itip.transport":
|
||||
if (this.hasAutoScheduling || this.hasScheduling) {
|
||||
return this.QueryInterface(Components.interfaces.calIItipTransport);
|
||||
|
|
|
@ -59,8 +59,6 @@ pref("calendar.alarms.todoalarmunit", "minutes");
|
|||
pref("calendar.alarms.defaultsnoozelength", 5);
|
||||
pref("calendar.alarms.indicator.show", true);
|
||||
pref("calendar.alarms.indicator.totaltime", 3600);
|
||||
pref("calendar.autorefresh.enabled", true);
|
||||
pref("calendar.autorefresh.timeout", 30);
|
||||
pref("calendar.date.format", 0);
|
||||
pref("calendar.event.defaultlength", 60);
|
||||
// Do NOT set this. If it is unset, we guess the timezone from the system
|
||||
|
|
Загрузка…
Ссылка в новой задаче