Fixing publishing so that you can now publish an entire calendar or just the selected events.

This commit is contained in:
mikep%oeone.com 2003-02-06 18:06:18 +00:00
Родитель d12037cd31
Коммит 6cdc18391a
7 изменённых файлов: 69 добавлений и 56 удалений

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

@ -1038,6 +1038,25 @@ function publishEntireCalendar()
var args = new Object();
args.onOk = self.publishEntireCalendarDialogResponse;
var name = gCalendarWindow.calendarManager.getSelectedCalendarId();
var node = gCalendarWindow.calendarManager.rdf.getNode( name );
var remotePath = node.getAttribute( "http://home.netscape.com/NC-rdf#remotePath" );
if( remotePath != "" )
{
var publishObject = new Object( );
publishObject.username = node.getAttribute( "http://home.netscape.com/NC-rdf#username" );
//get the url and the filename from the remotePath
var arrayOfPath = remotePath.split( "/" );
publishObject.filename = arrayOfPath.pop();
publishObject.url = remotePath.substr( 0, ( remotePath.length - publishObject.filename.length) );
publishObject.password = node.getAttribute( "http://home.netscape.com/NC-rdf#password" );
args.publishObject = publishObject;
}
openDialog("chrome://calendar/content/publishDialog.xul", "caPublishEvents", "chrome,modal", args );
}

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

@ -121,7 +121,7 @@
<command id="close_calendar_command" key="key_close" oncommand="closeCalendar()"/>
<command id="wizard_command" oncommand="launchWizard()"/>
<command id="wizard_command" oncommand="launchWizard()" collapsed="true"/>
</commandset>
<keyset>

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

@ -667,11 +667,10 @@ function eventArrayToICalString( calendarEventArray, doPatchForExport )
for( var eventArrayIndex = 0; eventArrayIndex < calendarEventArray.length; ++eventArrayIndex )
{
var calendarEvent = calendarEventArray[ eventArrayIndex ].clone();
// convert time to represent local to produce correct DTSTART and DTEND
if(calendarEvent.allDay != true)
convertLocalToZulu( calendarEvent );
convertLocalToZulu( calendarEvent );
// check if all required properties are available
if( calendarEvent.method == 0 )
calendarEvent.method = calendarEvent.ICAL_METHOD_PUBLISH;
@ -683,7 +682,7 @@ function eventArrayToICalString( calendarEventArray, doPatchForExport )
else
sTextiCalendar += calendarEvent.getIcalString() ;
}
return sTextiCalendar;
}

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

@ -9,7 +9,7 @@ IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Collabnet code.
The Original Code is jslib code.
The Initial Developer of the Original Code is jslib team.
Portions created by jslib team are
@ -128,12 +128,14 @@ const JS_FILE_FILE = "file.js";
const JS_FILE_F_CHANNEL_CID = "@mozilla.org/network/local-file-channel;1";
const JS_FILE_IOSERVICE_CID = "@mozilla.org/network/io-service;1";
const JS_FILE_I_STREAM_CID = "@mozilla.org/scriptableinputstream;1";
const JS_FILE_OUTSTREAM_CID = "@mozilla.org/network/file-output-stream;1";
const JS_FILE_F_TRANSPORT_SERVICE_CID = "@mozilla.org/network/file-transport-service;1";
const JS_FILE_I_FILE_CHANNEL = "nsIFileChannel";
const JS_FILE_I_IOSERVICE = C.interfaces.nsIIOService;
const JS_FILE_I_SCRIPTABLE_IN_STREAM = "nsIScriptableInputStream";
const JS_FILE_I_FILE_OUT_STREAM = C.interfaces.nsIFileOutputStream;
const JS_FILE_READ = 0x01; // 1
const JS_FILE_WRITE = 0x08; // 8
@ -160,15 +162,6 @@ try {
const JS_FILE_IOSERVICE = C.classes[JS_FILE_IOSERVICE_CID].
getService(JS_FILE_I_IOSERVICE);
/***
* The File Transport Service provides nsITransport objects
* which can supply nsIOutputStream objects for writing to files.
*/
const JS_FILE_FileTransportService =
C.classes[JS_FILE_F_TRANSPORT_SERVICE_CID].
getService(C.interfaces.nsIFileTransportService);
} catch (e) {
jslibError (e, "open("+this.mMode+") (unable to get nsIFileChannel)",
"NS_ERROR_FAILURE",
@ -176,11 +169,7 @@ try {
}
/***
* Possible values for the ioFlags parameter to
* FileTransportService.createTransport.
*/
/***
* Possible values for the ioFlags parameter
* From:
* http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/include/prio.h#601
*/
@ -325,35 +314,35 @@ File.prototype.open = function(aMode, aPerms)
var offSet=0;
if (aMode == JS_FILE_WRITE_MODE) {
this.mMode=JS_FILE_WRITE_MODE;
// Create a file transport in write mode
if (!this.mTransport) {
this.mTransport = JS_FILE_FileTransportService.createTransport
(this.mFileInst,
JS_FILE_NS_WRONLY | JS_FILE_NS_CREATE_FILE |
JS_FILE_NS_TRUNCATE, aPerms, true);
}
// create a filestream
var fs = C.classes[JS_FILE_OUTSTREAM_CID].
createInstance(JS_FILE_I_FILE_OUT_STREAM);
fs.init(this.mFileInst, JS_FILE_NS_TRUNCATE |
JS_FILE_NS_WRONLY, 00004, null);
this.mOutStream = fs;
} else {
this.mMode=JS_FILE_APPEND_MODE;
if (!this.mTransport) {
this.mTransport = JS_FILE_FileTransportService.createTransport(
this.mFileInst,
JS_FILE_NS_CREATE_FILE | JS_FILE_NS_WRONLY
| JS_FILE_NS_APPEND,
aPerms, true);
}
jslib_debug("this.mTransport: "+this.mTransport);
// create a filestream
var fs = C.classes[JS_FILE_OUTSTREAM_CID].
createInstance(JS_FILE_I_FILE_OUT_STREAM);
fs.init(this.mFileInst, JS_FILE_NS_RDWR |
JS_FILE_NS_APPEND, 00004, null);
this.mOutStream = fs;
}
} catch(e) {
jslibError(e, "open("+this.mMode+") (unable to get transport)",
"NS_ERROR_FAILURE",
JS_FILE_FILE+":open");
jslibError(e, "open("+this.mMode+") (unable to get file stream)",
"NS_ERROR_FAILURE",
JS_FILE_FILE+":open");
return null;
}
try {
// Use the previously created file transport to open an output
// stream for writing to the file
if (!this.mOutStream) {
this.mOutStream = this.mTransport.openOutputStream(offSet, -1, 0);
// this.mOutStream = this.mTransport.openOutputStream(offSet, -1, 0);
// this.mOutStream =
}
} catch(e) {
jslibError(e, "open("+this.mMode+") (unable to get outputstream)",
@ -378,15 +367,13 @@ File.prototype.open = function(aMode, aPerms)
try {
this.mFileChannel = JS_FILE_IOSERVICE.newChannelFromURI(this.mURI);
this.mInputStream = new JS_FILE_InputStream();
this.mLineBuffer = new Array();
this.mFileChannel.init(this.mFileInst, JS_FILE_READ, this.permissions);
this.mInputStream.init(this.mFileChannel.open());
this.mLineBuffer = new Array();
rv=true;
} catch (e) {
jslibError(e, "open(r) (error setting permissions)",
"NS_ERROR_FAILURE",
JS_FILE_FILE+":open");
JS_FILE_FILE+":open\n"+e);
return null;
}
break;
@ -571,14 +558,14 @@ File.prototype.write = function(aBuffer, aPerms)
"NS_ERROR_FAILURE",
JS_FILE_FILE+":write");
this.close();
return false;
return null;
}
if (!this.mFileInst) {
jslibError(null, "(no file instance)",
"NS_ERROR_NOT_INITIALIZED",
JS_FILE_FILE+":write");
return false;
return null;
}
if (!aBuffer)

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

@ -78,14 +78,12 @@ function calendarPublish(aDataString, newLocation, fileName, login, password, co
dump("failed to get a destination channel\n");
return;
}
output_string_to_channel(protocolChannel, aDataString, contentType);
protocolChannel.asyncOpen(gPublishingListener, null);
dump("done\n");
}
}
catch (e)
{
alert("an error occurred: " + e + "\n");
alert("an error occurred in calendarPublish: " + e + "\n");
}
}
@ -107,7 +105,7 @@ function calendarUploadFile(aSourceFilename, newLocation, fileName, login, passw
}
catch (e)
{
alert("an error occurred: " + e + "\n");
alert("an error occurred in calendarUploadFile: " + e + "\n");
}
}

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

@ -97,12 +97,22 @@ function loadCalendarPublishDialog()
gOnOkFunction = args.onOk;
//get default values from the prefs
document.getElementById( "publish-url-textbox" ).value = opener.getCharPref( opener.gCalendarWindow.calendarPreferences.calendarPref, "publish.path", "" );
document.getElementById( "publish-remotefilename-textbox" ).value = opener.getCharPref( opener.gCalendarWindow.calendarPreferences.calendarPref, "publish.filename", "" );
document.getElementById( "publish-username-textbox" ).value = opener.getCharPref( opener.gCalendarWindow.calendarPreferences.calendarPref, "publish.username", "" );
document.getElementById( "publish-password-textbox" ).value = opener.getCharPref( opener.gCalendarWindow.calendarPreferences.calendarPref, "publish.password", "" );
if( args.publishObject )
{
document.getElementById( "publish-url-textbox" ).value = args.publishObject.url;
document.getElementById( "publish-remotefilename-textbox" ).value = args.publishObject.filename;
document.getElementById( "publish-username-textbox" ).value = args.publishObject.username;
document.getElementById( "publish-password-textbox" ).value = args.publishObject.password;
}
else
{
//get default values from the prefs
document.getElementById( "publish-url-textbox" ).value = opener.getCharPref( opener.gCalendarWindow.calendarPreferences.calendarPref, "publish.path", "" );
document.getElementById( "publish-remotefilename-textbox" ).value = opener.getCharPref( opener.gCalendarWindow.calendarPreferences.calendarPref, "publish.filename", "" );
document.getElementById( "publish-username-textbox" ).value = opener.getCharPref( opener.gCalendarWindow.calendarPreferences.calendarPref, "publish.username", "" );
document.getElementById( "publish-password-textbox" ).value = opener.getCharPref( opener.gCalendarWindow.calendarPreferences.calendarPref, "publish.password", "" );
}
var firstFocus = document.getElementById( "publish-url-textbox" );
firstFocus.focus();
}

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

@ -76,7 +76,7 @@
<!ENTITY calendar.subscribe.label "Subscribe To Remote Calendar...">
<!ENTITY calendar.subscribe.accesskey "s">
<!ENTITY calendar.publish.label "Publish Events...">
<!ENTITY calendar.publish.label "Publish Selected Events...">
<!ENTITY calendar.publish.accesskey "p">
<!ENTITY calendar.about.label "About Calendar">