mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 07:05:24 +00:00
Bug 177109 Commandline handling for subscribing and jumping to specific dates, r=mvl
This commit is contained in:
parent
4cfa9c25de
commit
a5059eb2e4
@ -131,6 +131,50 @@ function calendarInit()
|
||||
|
||||
document.getElementById("view-deck")
|
||||
.addEventListener("dayselect", observeViewDaySelect, false);
|
||||
|
||||
// Handle commandline args
|
||||
for (var i=0; i < window.arguments.length; i++) {
|
||||
try {
|
||||
var cl = window.arguments[i].QueryInterface(Components.interfaces.nsICommandLine);
|
||||
} catch(ex) {
|
||||
dump("unknown argument passed to main window\n");
|
||||
continue;
|
||||
}
|
||||
handleCommandLine(cl);
|
||||
}
|
||||
}
|
||||
|
||||
function handleCommandLine(aComLine) {
|
||||
var calurl;
|
||||
try {
|
||||
calurl = aComLine.handleFlagWithParam("subscribe", false);
|
||||
} catch(ex) {}
|
||||
if (calurl) {
|
||||
var uri = makeURL(calurl);
|
||||
var cal = getCalendarManager().createCalendar('ics', uri);
|
||||
getCalendarManager().registerCalendar(cal);
|
||||
|
||||
// Strip ".ics" from filename for use as calendar name, taken from
|
||||
// calendarCreation.js
|
||||
var fullPathRegex = new RegExp("([^/:]+)[.]ics$");
|
||||
var prettyName = calurl.match(fullPathRegex);
|
||||
var name;
|
||||
|
||||
if (prettyName && prettyName.length >= 1) {
|
||||
name = decodeURIComponent(prettyName[1]);
|
||||
} else {
|
||||
name = calGetString("calendar", "untitledCalendarName");
|
||||
}
|
||||
cal.name = name;
|
||||
}
|
||||
|
||||
var date;
|
||||
try {
|
||||
date = aComLine.handleFlagWithParam("showdate", false);
|
||||
} catch(ex) {}
|
||||
if (date) {
|
||||
currentView().goToDay(jsDateToDateTime(new Date(date)));
|
||||
}
|
||||
}
|
||||
|
||||
/* Called at midnight to tell us to update the views and other ui bits */
|
||||
|
@ -123,16 +123,18 @@ CLineService.prototype = {
|
||||
/* nsICommandLineHandler */
|
||||
|
||||
handle : function service_handle(cmdLine) {
|
||||
if (cmdLine.handleFlag("calendar", false)) {
|
||||
wwatch = Components.classes[WINDOWWATCHER_CONTRACTID]
|
||||
.getService(nsIWindowWatcher);
|
||||
wwatch.openWindow(null, "chrome://calendar/content/",
|
||||
// just pass all arguments on to the Sunbird window
|
||||
wwatch = Components.classes[WINDOWWATCHER_CONTRACTID]
|
||||
.getService(nsIWindowWatcher);
|
||||
wwatch.openWindow(null, "chrome://calendar/content/",
|
||||
"_blank", "chrome,dialog=no,all", cmdLine);
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
cmdLine.preventDefault = true;
|
||||
},
|
||||
|
||||
helpInfo : " -calendar Start with the calendar.\n"
|
||||
helpInfo : " -subscribe Pass in a path pointing to a calendar\n" +
|
||||
" to subscribe to.\n" +
|
||||
" -showdate Pass in a value for a javascript date\n" +
|
||||
" to show this date on startup.\n"
|
||||
};
|
||||
|
||||
/* factory for command line handler service (CLineService) */
|
||||
|
Loading…
Reference in New Issue
Block a user