Checked in patch for bug 193467: adding a calendar can replace an existing one (calendarManager).

( Except for the default calendar name change )
This commit is contained in:
mostafah%oeone.com 2003-10-01 15:49:32 +00:00
Родитель 0c93169c06
Коммит eac18e220b
1 изменённых файлов: 32 добавлений и 12 удалений

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

@ -20,6 +20,7 @@
*
* Contributor(s): Mike Potter <mikep@oeone.com>
* Eric Belhaire <belhaire@ief.u-psud.fr>
* Matthew Buckett <buckett@bumph.org>
*
* 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
@ -263,15 +264,15 @@ calendarManager.prototype.launchEditRemoteCalendarDialog = function calMan_launc
*/
calendarManager.prototype.addServerDialogResponse = function calMan_addServerDialogResponse( CalendarObject )
{
var now = new Date();
var name = "calendar"+now.getTime();
var next = this.nextCalendar();
var name = "calendar"+next;
CalendarObject.active = true;
CalendarObject.remotePath = CalendarObject.remotePath.replace( "webcal:", "http:" );
var node = this.rootContainer.addNode(name);
node.setAttribute("http://home.netscape.com/NC-rdf#active", "true");
node.setAttribute("http://home.netscape.com/NC-rdf#serverNumber", this.rootContainer.getSubNodes().length);
node.setAttribute("http://home.netscape.com/NC-rdf#serverNumber", next);
node.setAttribute("http://home.netscape.com/NC-rdf#name", CalendarObject.name);
var profileFile;
@ -281,7 +282,7 @@ calendarManager.prototype.addServerDialogResponse = function calMan_addServerDia
//they didn't set a path in the box, that's OK, its not required.
profileFile = this.getProfileDirectory();
profileFile.append("Calendar");
profileFile.append("CalendarDataFile"+this.rootContainer.getSubNodes().length+".ics");
profileFile.append("CalendarDataFile"+ next+ ".ics");
CalendarObject.path = profileFile.path;
}
@ -296,7 +297,7 @@ calendarManager.prototype.addServerDialogResponse = function calMan_addServerDia
{
profileFile = this.getProfileDirectory();
profileFile.append( "Calendar" );
profileFile.append("RemoteCalendar"+this.rootContainer.getSubNodes().length+".ics");
profileFile.append("RemoteCalendar"+ next+ ".ics");
node.setAttribute("http://home.netscape.com/NC-rdf#remote", "true");
@ -306,13 +307,13 @@ calendarManager.prototype.addServerDialogResponse = function calMan_addServerDia
node.setAttribute("http://home.netscape.com/NC-rdf#password", CalendarObject.password);
this.retrieveAndSaveRemoteCalendar( node );
dump( "Remote Calendar Number "+this.rootContainer.getSubNodes().length+" Added" );
dump( "Remote Calendar Number "+ next+ " Added\n" );
}
else
{
node.setAttribute("http://home.netscape.com/NC-rdf#remote", "false");
dump( "Calendar Number "+CalendarObject.serverNumber+" Added" );
dump( "Calendar Number "+CalendarObject.serverNumber+" Added\n" );
}
this.rdf.flush();
@ -328,6 +329,24 @@ calendarManager.prototype.addServerDialogResponse = function calMan_addServerDia
calendarColorStyleRuleUpdate( CalendarObject );
}
/**
* Finds the maximum calendar id used in the RDF datasource.
*/
calendarManager.prototype.nextCalendar = function calMan_getNextCalendar()
{
var seq = this.rootContainer.getSubNodes();
var max = -1;
var subject;
for (var count = 0; count < seq.length; count++ ) {
subject = seq[count].getSubject();
subject = subject.replace(/^.*calendar(\d+)$/, "$1");
if (subject > max) max = subject;
}
return ++max;
}
/*
** Called when OK is clicked in the edit localCalendar dialog.
@ -628,7 +647,7 @@ calendarManager.prototype.checkCalendarURL = function calMan_checkCalendarURL( C
var profileFile = CalendarManager.getProfileDirectory();
profileFile.append("Calendar");
profileFile.append("Email"+CalendarManager.rootContainer.getSubNodes().length+".ics");
profileFile.append("Email"+ this.nextCalendar()+ ".ics");
FilePath = profileFile.path;
saveDataToFile(FilePath, CalendarData, null);
@ -762,19 +781,20 @@ calendarManager.prototype.getAndConvertAllOldCalendars = function calMan_getAllC
dump( "error: could not get calendar information from preferences\n"+e );
}
var name = "calendar"+this.rootContainer.getSubNodes().length;
var nameId = this.nextCalendar();
var name = "calendar"+ nameId;
//now convert it, and put it in the RDF file.
var node = this.rootContainer.addNode(name);
node.setAttribute("http://home.netscape.com/NC-rdf#active", thisCalendar.name);
node.setAttribute("http://home.netscape.com/NC-rdf#serverNumber", this.rootContainer.getSubNodes().length);
node.setAttribute("http://home.netscape.com/NC-rdf#serverNumber", nameId);
node.setAttribute("http://home.netscape.com/NC-rdf#name", thisCalendar.name);
if( thisCalendar.remote == true )
{
var profileFile = this.getProfileDirectory();
profileFile.append( "Calendar" );
profileFile.append("RemoteCalendar"+this.rootContainer.getSubNodes().length+".ics");
profileFile.append("RemoteCalendar"+ nameId);
var CalendarPath = profileFile.path;
}
else
@ -790,7 +810,7 @@ calendarManager.prototype.getAndConvertAllOldCalendars = function calMan_getAllC
//if the file CalendarDataFile.ics exists in the users profile directory, move it to Calendar/CalendarDataFile.ics
newCalendarFile = this.getProfileDirectory();
newCalendarFile.append( "Calendar" );
newCalendarFile.append( "RemoteCalendar"+this.rootContainer.getSubNodes().length+".ics" );
newCalendarFile.append( "RemoteCalendar"+this.nextCalendar()+".ics" );
oldCalendarDataFile = new File( thisCalendar.path );
newCalendarDataFile = new File( newCalendarFile.path );