зеркало из https://github.com/mozilla/pjs.git
persisting calendar name and name changes using calendar prefs (bug 292097) r=shaver
This commit is contained in:
Родитель
70410f78e2
Коммит
a900c05973
|
@ -47,10 +47,9 @@ interface calICalendarManager : nsISupports
|
|||
{
|
||||
/*
|
||||
* create a new calendar
|
||||
* aName is the display name of the calendar
|
||||
* aType is the type ("caldav", "storage", etc)
|
||||
*/
|
||||
calICalendar createCalendar(in AUTF8String aName, in AUTF8String aType, in nsIURI aURL);
|
||||
calICalendar createCalendar(in AUTF8String aType, in nsIURI aURL);
|
||||
|
||||
/* register a newly created calendar with the calendar service */
|
||||
void registerCalendar(in calICalendar aCalendar);
|
||||
|
|
|
@ -102,8 +102,8 @@ calCalendarManager.prototype = {
|
|||
},
|
||||
|
||||
initDB: function() {
|
||||
var sqlTables = { cal_calendars: "id INTEGER PRIMARY KEY, name STRING, type STRING, uri STRING",
|
||||
cal_calendars_prefs: "id INTEGER PRIMARY KEY, calendar INTERGER, name STRING, value STRING"
|
||||
var sqlTables = { cal_calendars: "id INTEGER PRIMARY KEY, type STRING, uri STRING",
|
||||
cal_calendars_prefs: "id INTEGER PRIMARY KEY, calendar INTEGER, name STRING, value STRING"
|
||||
};
|
||||
|
||||
var dbService = Components.classes[kStorageServiceContractID].getService(kStorageServiceIID);
|
||||
|
@ -124,12 +124,12 @@ calCalendarManager.prototype = {
|
|||
|
||||
this.mFindCalendar = createStatement (
|
||||
this.mDB,
|
||||
"SELECT id FROM cal_calendars WHERE name = :name AND type = :type AND uri = :uri");
|
||||
"SELECT id FROM cal_calendars WHERE type = :type AND uri = :uri");
|
||||
|
||||
this.mRegisterCalendar = createStatement (
|
||||
this.mDB,
|
||||
"INSERT INTO cal_calendars (name, type, uri) " +
|
||||
"VALUES (:name, :type, :uri)"
|
||||
"INSERT INTO cal_calendars (type, uri) " +
|
||||
"VALUES (:type, :uri)"
|
||||
);
|
||||
|
||||
this.mUnregisterCalendar = createStatement (
|
||||
|
@ -150,14 +150,12 @@ calCalendarManager.prototype = {
|
|||
"INSERT INTO cal_calendars_prefs (calendar, name, value) " +
|
||||
"VALUES (:calendar, :name, :value)");
|
||||
|
||||
|
||||
},
|
||||
|
||||
findCalendarID: function(calendar) {
|
||||
var stmt = this.mFindCalendar;
|
||||
stmt.reset();
|
||||
var pp = stmt.params;
|
||||
pp.name = calendar.name;
|
||||
pp.type = calendar.type;
|
||||
pp.uri = calendar.uri.spec;
|
||||
|
||||
|
@ -173,9 +171,8 @@ calCalendarManager.prototype = {
|
|||
/**
|
||||
* calICalendarManager interface
|
||||
*/
|
||||
createCalendar: function(name, type, uri) {
|
||||
createCalendar: function(type, uri) {
|
||||
var calendar = Components.classes["@mozilla.org/calendar/calendar;1?type=" + type].createInstance(Components.interfaces.calICalendar);
|
||||
calendar.name = name;
|
||||
calendar.uri = uri;
|
||||
return calendar;
|
||||
},
|
||||
|
@ -186,7 +183,6 @@ calCalendarManager.prototype = {
|
|||
throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
var pp = this.mRegisterCalendar.params;
|
||||
pp.name = calendar.name;
|
||||
pp.type = calendar.type;
|
||||
pp.uri = calendar.uri.spec;
|
||||
|
||||
|
@ -228,9 +224,9 @@ calCalendarManager.prototype = {
|
|||
var id = stmt.row.id;
|
||||
if (!this.mCache[id]) {
|
||||
try {
|
||||
this.mCache[id] = this.createCalendar(stmt.row.name, stmt.row.type, makeURI(stmt.row.uri));
|
||||
this.mCache[id] = this.createCalendar(stmt.row.type, makeURI(stmt.row.uri));
|
||||
} catch (e) {
|
||||
dump("Can't create calendar for " + id + " (" + stmt.row.name + ", " + stmt.row.type + ", " +
|
||||
dump("Can't create calendar for " + id + " (" + stmt.row.type + ", " +
|
||||
stmt.row.uri + "): " + e + "\n");
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,10 @@ const calITodo = Components.interfaces.calITodo;
|
|||
const calEventClass = Components.classes["@mozilla.org/calendar/event;1"];
|
||||
const calIItemOccurrence = Components.interfaces.calIItemOccurrence;
|
||||
|
||||
const kCalCalendarManagerContractID = "@mozilla.org/calendar/manager;1";
|
||||
const kCalICalendarManager = Components.interfaces.calICalendarManager;
|
||||
|
||||
|
||||
function makeOccurrence(item, start, end)
|
||||
{
|
||||
var occ = Components.classes["@mozilla.org/calendar/item-occurrence;1"].
|
||||
|
@ -81,6 +85,16 @@ function makeOccurrence(item, start, end)
|
|||
|
||||
return occ;
|
||||
}
|
||||
|
||||
var activeCalendarManager = null;
|
||||
function getCalendarManager()
|
||||
{
|
||||
if (!activeCalendarManager) {
|
||||
activeCalendarManager =
|
||||
Components.classes[kCalCalendarManagerContractID].getService(kCalICalendarManager);
|
||||
}
|
||||
return activeCalendarManager;
|
||||
}
|
||||
|
||||
// END_OF_TIME needs to be the max value a PRTime can be
|
||||
const START_OF_TIME = -0x7fffffffffffffff;
|
||||
|
@ -104,7 +118,12 @@ calDavCalendar.prototype = {
|
|||
//
|
||||
|
||||
// attribute AUTF8String name;
|
||||
name: "",
|
||||
get name() {
|
||||
return getCalendarManager().getCalendarPref(this, "NAME");
|
||||
},
|
||||
set name(name) {
|
||||
getCalendarManager().setCalendarPref(this, "NAME", name);
|
||||
},
|
||||
|
||||
// readonly attribute AUTF8String type;
|
||||
get type() { return "caldav"; },
|
||||
|
|
|
@ -47,6 +47,19 @@
|
|||
|
||||
const calIOperationListener = Components.interfaces.calIOperationListener;
|
||||
const calICalendar = Components.interfaces.calICalendar;
|
||||
const calCalendarManagerContractID = "@mozilla.org/calendar/manager;1";
|
||||
const calICalendarManager = Components.interfaces.calICalendarManager;
|
||||
|
||||
var activeCalendarManager = null;
|
||||
function getCalendarManager()
|
||||
{
|
||||
if (!activeCalendarManager) {
|
||||
activeCalendarManager =
|
||||
Components.classes[calCalendarManagerContractID].getService(calICalendarManager);
|
||||
}
|
||||
return activeCalendarManager;
|
||||
}
|
||||
|
||||
|
||||
function calICSCalendar () {
|
||||
this.wrappedJSObject = this;
|
||||
|
@ -84,7 +97,12 @@ calICSCalendar.prototype = {
|
|||
this.mMemoryCalendar.addObserver(this.mObserver);
|
||||
},
|
||||
|
||||
name: "",
|
||||
get name() {
|
||||
return getCalendarManager().getCalendarPref(this, "NAME");
|
||||
},
|
||||
set name(name) {
|
||||
getCalendarManager().setCalendarPref(this, "NAME", name);
|
||||
},
|
||||
|
||||
get type() { return "ics"; },
|
||||
|
||||
|
|
|
@ -40,6 +40,19 @@
|
|||
// calMemoryCalendar.js
|
||||
//
|
||||
|
||||
const calCalendarManagerContractID = "@mozilla.org/calendar/manager;1";
|
||||
const calICalendarManager = Components.interfaces.calICalendarManager;
|
||||
|
||||
var activeCalendarManager = null;
|
||||
function getCalendarManager()
|
||||
{
|
||||
if (!activeCalendarManager) {
|
||||
activeCalendarManager =
|
||||
Components.classes[calCalendarManagerContractID].getService(calICalendarManager);
|
||||
}
|
||||
return activeCalendarManager;
|
||||
}
|
||||
|
||||
function calMemoryCalendar() {
|
||||
this.wrappedJSObject = this;
|
||||
this.initMemoryCalendar();
|
||||
|
@ -83,7 +96,12 @@ calMemoryCalendar.prototype = {
|
|||
//
|
||||
|
||||
// attribute AUTF8String name;
|
||||
name: "",
|
||||
get name() {
|
||||
return getCalendarManager().getCalendarPref(this, "NAME");
|
||||
},
|
||||
set name(name) {
|
||||
getCalendarManager().setCalendarPref(this, "NAME", name);
|
||||
},
|
||||
|
||||
// readonly attribute AUTF8String type;
|
||||
get type() { return "memory"; },
|
||||
|
|
|
@ -45,6 +45,9 @@ const kStorageServiceIID = Components.interfaces.mozIStorageService;
|
|||
|
||||
const kCalICalendar = Components.interfaces.calICalendar;
|
||||
|
||||
const kCalCalendarManagerContractID = "@mozilla.org/calendar/manager;1";
|
||||
const kCalICalendarManager = Components.interfaces.calICalendarManager;
|
||||
|
||||
const kCalEventContractID = "@mozilla.org/calendar/event;1";
|
||||
const kCalIEvent = Components.interfaces.calIEvent;
|
||||
var CalEvent;
|
||||
|
@ -184,6 +187,16 @@ function makeOccurrence(item, start, end)
|
|||
// calStorageCalendar
|
||||
//
|
||||
|
||||
var activeCalendarManager = null;
|
||||
function getCalendarManager()
|
||||
{
|
||||
if (!activeCalendarManager) {
|
||||
activeCalendarManager =
|
||||
Components.classes[kCalCalendarManagerContractID].getService(kCalICalendarManager);
|
||||
}
|
||||
return activeCalendarManager;
|
||||
}
|
||||
|
||||
function calStorageCalendar() {
|
||||
this.wrappedJSObject = this;
|
||||
}
|
||||
|
@ -216,8 +229,12 @@ calStorageCalendar.prototype = {
|
|||
//
|
||||
|
||||
// attribute AUTF8String name;
|
||||
name: "",
|
||||
|
||||
get name() {
|
||||
return getCalendarManager().getCalendarPref(this, "NAME");
|
||||
},
|
||||
set name(name) {
|
||||
getCalendarManager().setCalendarPref(this, "NAME", name);
|
||||
},
|
||||
// readonly attribute AUTF8String type;
|
||||
get type() { return "storage"; },
|
||||
|
||||
|
|
|
@ -82,13 +82,15 @@ function doCreateCalendar()
|
|||
|
||||
var calManager = getCalendarManager();
|
||||
try {
|
||||
var newCalendar = calManager.createCalendar(cal_name, provider, makeURL(uri));
|
||||
var newCalendar = calManager.createCalendar(provider, makeURL(uri));
|
||||
} catch (ex) {
|
||||
dump(ex);
|
||||
return false;
|
||||
}
|
||||
calManager.registerCalendar(newCalendar);
|
||||
|
||||
newCalendar.name = cal_name;
|
||||
|
||||
calManager.setCalendarPref(newCalendar, 'color', cal_color);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -71,6 +71,7 @@ function onOKCommand()
|
|||
gCalendar.uri = newUri;
|
||||
|
||||
var calManager = getCalendarManager();
|
||||
|
||||
calManager.setCalendarPref(gCalendar, 'color',
|
||||
document.getElementById("calendar-color").color);
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ function loadCalendarEventDialog()
|
|||
} catch(ex) {
|
||||
dump("eventCalendar.uri not found...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update enabling and disabling
|
||||
updateRepeatItemEnabled();
|
||||
|
|
Загрузка…
Ссылка в новой задаче