Closed Bug 359807 Opened 18 years ago Closed 2 years ago

No command line switch to start Thunderbird with calendar view upon start-up

Categories

(Calendar :: General, enhancement)

enhancement
Not set
normal

Tracking

(thunderbird_esr91 wontfix, thunderbird_esr102+ fixed)

VERIFIED FIXED
104 Branch
Tracking Status
thunderbird_esr91 --- wontfix
thunderbird_esr102 + fixed

People

(Reporter: giermann, Assigned: rjl)

References

(Blocks 3 open bugs)

Details

Attachments

(2 files, 5 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7

I tried previous options for Calendar extension (thunderbird.exe -mail -calendar) and only "-calendar"; but TB always starts with the default view...

I would like an option to start in Month-View to see all recent and coming events, like I do in Sunbird on start-up!

Reproducible: Always

Steps to Reproduce:
1. Install TB 1.5.0.7
2. Install Lightning 0.3
3. Start "...\thunderbird.exe -calendar"

Actual Results:  
TB starts normal.

Expected Results:  
TB starts in Lightning-View.

I also tried this with Lightning 0.4a1 (nightly from 02. November) - same result.
Version: unspecified → Lightning 0.3
Yes, this is covered here:

http://www.mozilla.org/projects/calendar/faq.html#shortcut

But I can confirm -calendar is not working.

Thunderbird 1.5.0.8
Windows
Lightning 0.3
Status: UNCONFIRMED → NEW
Ever confirmed: true
I tried several ways now, but I think there's only one workaround without modifying Thunderbird...

Whenever TB is configured to download mails upon startup, it selects the Inbox folder of the default account. This occurs AFTER Lightning is loaded, so Lighting is unable to bring the calendar up.

One workaround would be to use an internal URL (i.e. 'about:calendar'), because TB does not select the folder view, when it is started with a URL; it displays this URL instead!

I got this working, even with the desired view ('about:calendar-month' etc.) - but I'm not sure, whether this is the right way to go...
Wouldn't it be better to completely handle this URL instead, although it does not really make sense in Thunderbird?!

What do you all think about that?
Doesn't work in 1.5.0.12 or 2.0.0.5 for me using
"C:\Program Files\Mozilla Thunderbird\thunderbird.exe" -about:calendar-month
or
"C:\Program Files\Mozilla Thunderbird\thunderbird.exe" about:calendar-month

What did you use as a workaround?
Bas, sorry for being so imprecise. This start option is not supported - but could be; implement attached patch.

Stefan, what do you think about this 'new' start-up option?
Maybe we have to add another line to display the sidebar in mail-mode, too? But I think this is already covered in another bug, although I did not find it to add a reference here...

The patch currently searches the requested view and selects this or month-view as default, so the following start options become available in current nightly builds:
  ...\thunderbird.exe about:calendar
  ...\thunderbird.exe about:calendar-day
  ...\thunderbird.exe about:calendar-month
  ...\thunderbird.exe about:calendar-week
  ...\thunderbird.exe about:calendar-multiweek
Attachment #274582 - Flags: review?
Sven, you asked for review without a reviewer. Please choose an appropriate one from http://wiki.mozilla.org/Calendar:Module_Ownership.
Assignee: nobody → giermann
Status: NEW → ASSIGNED
OS: Windows XP → All
Hardware: PC → All
Attachment #274582 - Flags: review? → review?(ctalbert)
Comment on attachment 274582 [details] [diff] [review]
Enable 'about:calendar' and 'about:calendar-month' etc. for starting TB with Lightning-View

Thanks for your patch.  It looks really good.  I have a couple of mozilla style nits
that I have addressed below.  We keep everything less than 80 chars on a line where
it doesn't hurt readability.  That's so that diffs look decent in bonsai and
bugzilla.

>+    // display Calendar, when started with 'about:calendar' or 'about:calendar-[VIEW]'
Break this comment into two lines so that each line is less than 80 chars ^^

>+    if ( (window.arguments.length > 0) && window.arguments[0].substr(0, 14) == "about:calendar" ) {
Same with this if ^^ like so:
>+    if ( (window.arguments.length > 0) &&
>+       window.arguments[0].substr(0, 14) == "about:calendar" ) {


>+      var reqView = window.arguments[0].substr(15);
>+      // check, whether requested view exists
No need for comma in this statement ^

>+      setTimeout("showCalendarView('"+reqView+"');", 0);
I have tested this with a bunch of parameters, and I like the effect.  However,
I think we need to do just a little more.  If you try this with a current nightly,
you'll notice that you get the calendar pane, but the left "folderpane" area
is still the mail "folderpane" and not the calendar left pane.  Likewise,
the toolbar is still the mail toolbar and not the calendar toolbar.  I think this
means that you just need to add some extra calls to this function, but I think you
should check with mickey or Fallen on IRC about what you need to call in order
to fully switch us into the view.

I am eagerly awaiting the next version of the patch. But, I sadly have to r- this
because of the left pane and toolbar issues.
Attachment #274582 - Flags: review?(ctalbert) → review-
Attached patch patch rev.1 (obsolete) — Splinter Review
Clint,

your observation is already covered in Bug 386479, but as I recently found an easy way to fix this, I will attach a patch there soon.

So, this one only covers your additional comments.
Attachment #274582 - Attachment is obsolete: true
Attachment #277678 - Flags: review?(ctalbert)
I think that it would be cleaner to use a commandline switch instead of an url. The about: protocol is really handled somewhere else, and not in the power of lightning to change. The commandline switches are for consumers.

Besides that, does the patch work if I do 'thunderbird.exe -P foo about:calendar'?
(In reply to comment #9)
> I think that it would be cleaner to use a commandline switch instead of an url.
> The about: protocol is really handled somewhere else, and not in the power of
> lightning to change. The commandline switches are for consumers.

Well, I also tried this first, but there is a problem, when TB checks for new mails on start-up. TB does not recognize the '-calendar' switch and continues without attention to it.
This means, if no start page is requested it switches to the Inbox folder, after it downloaded new mails. This switches the view back to Mail-View.
By examining the code, I found that this does not take place, if any start page is requested in commandline.

I agree, that use of the about protocol is not the best way. You could use anything else ('calendar', 'calendar-month', 'calendar:month') - please post your ideas!
I don't know whether we could have a complete handler for a protocol like 'calendar:'...
But this would be an easy way for lots of people to start TB in Calendar view!

> Besides that, does the patch work if I do 'thunderbird.exe -P foo
> about:calendar'?

Yes, it does.

(In reply to comment #10)
> Well, I also tried this first, but there is a problem, when TB checks for new
> mails on start-up. TB does not recognize the '-calendar' switch and continues
> without attention to it.

I think Lightning needs to add/register a command handler for '-calendar' switch.  The old Mozilla Calendar extension did this so I don't know why Lightning should not be able to do the same.
(In reply to comment #11)
> I think Lightning needs to add/register a command handler for '-calendar'
> switch.  The old Mozilla Calendar extension did this so I don't know why
> Lightning should not be able to do the same.

The Problem is not Lightning, but Thunderbird. I played around with the old Mozilla Calendar... Version 0.8.x in Fx 1.0.0.7 switches to Calendar, when started with '-calendar'; version 0.2.x does'nt in Fx 1.5!
I modified the Calendar 0.2.x to install in Fx 1.0.0.7 and it starts in Calendar view (although reporting only errors) - but this shows, that the command handler was removed in Mozilla Code beginning with versions 1.5.
The way firefox (and thunderbird) handle commandline switches was changed, I think after fx1.0. Support for that was added to calendar after 0.2.x. So testing with older versions doesn't tell us much.
You need to look at calendarService.js for the code. Also, take a look at bug 378557, which also involves commandline stuff. Maybe that bug blocks this one.
mvl,

I tested the handling of commandline switches. I got a working solution now, but with two disadvantages:

1. I cannot test the existence of the views, because the document seems not to be loaded at this early time.

2. I have to create an own messenger window with the argument 'about:blank' to prevent loadStartFolder() to switch to the Inbox after biff.
But this would load 2 messenger windows, if also started with a start-page (i.e. 'thunderbird.exe about:blank -calendar')

To fix the 2nd, we would have to change Thunderbird code - right?
Cc'ing David Bienvenu on this bug so that he can answer the question in point 2 of comment 14.
What to do with all the permutations of command lines is complicated. If you're looking for a way to have an icon on the desktop that starts Thunderbird in Lightning mode, then it doesn't seem like you need to worry so much about other command line arguments...but if you're looking for how to handle it in all situations, I'm not sure that 2 messenger windows isn't the way to go. If I launch TB with -calendar and a .eml file, you'd want two windows, right?

I don't know what you mean by starting TB with a start page on the command line - that doesn't do anything. You can launch Thunderbird with a uri for a message, which loads that message, or a .eml file, which loads the .eml file. Conceivably, you could have a uri for a folder as well, to startup with that folder. But a start page doesn't do anything, afaik.
(In reply to comment #16)
> What to do with all the permutations of command lines is complicated. If you're
> looking for a way to have an icon on the desktop that starts Thunderbird in
> Lightning mode, then it doesn't seem like you need to worry so much about other
> command line arguments...but if you're looking for how to handle it in all
> situations, I'm not sure that 2 messenger windows isn't the way to go. If I
> launch TB with -calendar and a .eml file, you'd want two windows, right?

As we are talking about a bugfix in a public version, we should handle every situation. You are right, if someone starts 'foo.eml -calendar' he most likly wants both.

> I don't know what you mean by starting TB with a start page on the command line
> - that doesn't do anything. You can launch Thunderbird with a uri for a
> message, which loads that message, or a .eml file, which loads the .eml file.
> Conceivably, you could have a uri for a folder as well, to startup with that
> folder. But a start page doesn't do anything, afaik.

I refferred to the naming in 'msgMail3PaneWindow.js' and you are wrong, it does at least suppress the biff on startup and the selection of Inbox after biff, which is important to this issue...

I there any other way to suppress the (delayed) selection of Inbox?

when I run a trunk TB with a start page, e.g., thunderbird about:blank, it actually fails to bring up any UI, so in that sense, it does suppress the biff :-)

do you mean start folder uri? that's the folder we try to load at startup, and yes, that does prevent the selection of the inbox. 

If you've configured Thunderbird to select the inbox on startup, and download new messages, I'd think you might still want it to download new messages on startup, even if you launched it with the -calendar option.

I don't really know how your mail/calendar widget works internally. Why does selecting the start folder mess that widget up and prevent the calendar view from getting displayed? You could do something like listen for the onFolderLoaded notification, on startup, and switch to the calendar view after you receive that notification. Or are you simply trying to prevent Thunderbird from downloading new mail on startup?
David,

first - thank you for the quick replies and your explanations.
I did not check with the latest trunk, but TB 2.0.0.x brings up a window with an empty 'displayDeck'.
But I could verify the behaviour with the '-addressbook' switch - it also brings up the address book AND a message window, when 'about:blank' is appended.

To bring some light in:
- Lightning extends the 'displayDeck' and switches to calendar view by selecting another child in deck
- Starting with '-calendar' should not necessarily prevent the download of new messages, but if this is done, the Inbox is selected AFTER the download is complete --> the calendar would only display while downloading messages!

Maybe the observation of 'onFolderLoaded' would be an option, but I have another idea right now:

As the calendar view is just a special "location" displayed in the messenger window, I would advice to handle the display through a special uri, maybe with a special protocol...


@mvl: What do you think about handling 'calendar://month-view'?

The switch '-calendar' could just open a window with calendar view, but the behaviour of both would be slightly different:
- when you start TB with 'thunderbird.exe <uri1> <uri2>', only the first is being displayed
- when you start TB with 'thunderbird.exe <uri1> -calendar', two windows open up: one with <uri1> and another with calendar

I think the handling is a little complicated, because most commandline switches are used to display a dialog, not to modify the mail-view.
David,

(In reply to comment #16)
> Conceivably, you could have a uri for a folder as well, to startup with that
> folder. But a start page doesn't do anything, afaik.

I tested with latest trunk now - how do you start with a folder?
If I enter anything else than an .eml file, it does not bring an UI up...
So this at least produces errors with my 'about:calendar' in trunk!


The use of an url just feels wrong. The calendar view is not an url, it's just an option. Using an url to work around a problem isn't really clean imho.
Can't the lightning commandline handler eat any urls that are left? Maybe 'preventDefault' can help?
I agree with MVL, I think, in the sense that it shouldn't be a url that shows calendar...

Sven, see bug 386919 for how to start up with a particular message (not folder). It should work on the trunk, unless it's somehow regressed since I landed it.
Unfortunately I was not able to workaround all problems without changing TB code...

Furthermore I cannot manage to provide a working fix before 0.7 release - so I make a call to all others:

Please feel free to pick up this bug, if the solutions should be integrated into 0.7 release!
Version: Lightning 0.3 → unspecified
Sven, I don't think this is an issue that will block 0.7 release.  But I think it is something we want for 1.0 since it gives us a better embedability (is that a word) story, and allows further customization from the users.

Michiel, David, what should be the desired approach for this?  Should we do something like the "show message" functionality akin to what David pointed to in bug 386919?  Should we institute our own command line option handler (and overcome the objections there).  Is there some other approach that is worth looking at here?

Simon, I CC'd you just to get your opinion on where this sort of thing fits in the overall 1.0 strategy.  I'd like to hear your thoughts on that, as well as anyone else's.

Thanks ya'll.
I consider this a 5%-feature, meaning that probably only 5% of our users will likely ever use it. However, it would still be great to get this to work within the 1.0 timeframe.
Simon, David, Michiel, Sven, this bug is back on my radar after a while. I have read the comments here, and I'm still not totally sure that the patch I have for review is the approach we want.  Can you guys comment about your view on this?

My thought is this:

If our options are these:
1. "Fix thunderbird to do this right"
2. "Use this about handler as a workaround"
3. "Do something else to get command control working"

Then this is how I see things:
1. We should file bugs and patches to fix Thunderbird to do this right. But we can't depend on that code because 1.0 Lightning will need to work with Thunderbird 2.0, and the liklihood of these changes getting onto the MOZILLA_1_8_BRANCH are not high (though it should be said that they are not zero either).

2. I think we can use this handler as a workaround for any "Thunderbird" bug/feature that is stated in part 1.  I like this solution as a workaround because it is small, clean and will be easy to remove later.  Of course, insert here the general disclaimer that workaround code shouldn't ever be checked in since it never gets removed.

3. Is there another way to add command line handlers to thunderbird?  Didn't the old calendar extension have command line handlers?  Can we still do this, or was that feature destroyed during the MOZILLA_1_8_BRANCH effort?

I look forward to hearing your thoughts.  If we decide *not* to use the patch on this bug, then please clear the review request.
Clint,

with respect to comment #25 I think the best way would by the first (to fix TB).
I would even agree to leave out the workaround (2.) and to only use an extension for TB1/2 to start lightning with 'about:calendar'.

Unfortunately I don't have the knowledge to fix 1. or 2., but I could provide an extension as a workaround.
Bienvenu or Mvl: Can ya'll help me understand what the "right" fix for Thunderbird should be?  Then I'll make sure that bug is filed against Thunderbird trunk.  I'm with Sven and am a bit confused w.r.t. what needs to change there.  If there is no bug filed against Thunderbird for this feature, then I'd like to reassign this bug to Thunderbird so we don't lose the historical context.

Sven: Even if this were to somehow magically to be fixed on Thunderbird Trunk, the likelihood that the fix will be ported to the Thunderbird 2.x branch is very low.  Therefore, I'd like to ask you to consider providing this functionality in an extension.  Even five percent of our users is quite a measurable number of people, so I think it'd be a good extension to have available.  Feel free to open another bug in bugzilla to track your work on the extension.  Thanks for your patience and your help.

In light of this, I'm going to clear the review ? flag up above. 

Attachment #277678 - Flags: review?(ctalbert)
(In reply to comment #28)
> Bienvenu or Mvl: Can ya'll help me understand what the "right" fix for
> Thunderbird should be?  Then I'll make sure that bug is filed against
> Thunderbird trunk.  I'm with Sven and am a bit confused w.r.t. what needs to
> change there.

Thunderbird with Lightning installed needs to accept a "-calendar" switch on the command line when starting up, which presents the calendar view. That's the right fix, and it achieves parity with Seamonkey's calendar capability.

 - Chris
(In reply to comment #29)
> Thunderbird with Lightning installed needs to accept a "-calendar" switch on
> the command line when starting up, which presents the calendar view. That's the
> right fix, and it achieves parity with Seamonkey's calendar capability.

Of course, this is not very complicated to find out!

The question is: What has to be done by Lightning and was needs to be changed in TB...

IMHO TB needs an option for extensions to prevent the selection of the Inbox folder after Biff - this is essential to keep the calendar view after startup, even if the Biff ends after switching to calendar mode through Lightning startup.
Just my two cents: 
I think the users won't mind an extra extension for now and a fix in trunk. I think it's more important to have this working and with an extension we don't have to touch TB-2-code. 

As for the Addressbook: "thunderbird.exe -addressbook" does work but I think this is something different as the main-view of lightning doesn't open if you start Thunderbird this way. 
Why not just create a command line handler for -calendar inside of lightning and then handle the odd issues with Thunderbird wanting to load the mailbox within the command handler code?

This is From IRC:
[12:08pm] bienvenu_ joined the chat room.
[12:16pm] ctalbert|afk: bienvenu_: ping
[12:16pm] You are now known as ctalbert.
[12:16pm] bienvenu_: ctalbert - pong
[12:17pm] ctalbert: bienvenu_: Do you know what would need to be changed on the Thunderbird side for a -calendar option to work?  (bug 359807, comments 29-31)
[12:18pm] bienvenu_: ctalbert - I don't know. I like the idea of lightning having its own command line handler
[12:18pm] bienvenu_: I don't know if there needs to be some change to Thunderbird for that to happen (I doubt it would, though)
[12:18pm] bienvenu_: and I'm not sure if any changes to TB would be needed if Lightning did have its own command line handler...
[12:19pm] bienvenu_: sorry, that's not very helpful 
[12:19pm] Wolf joined the chat room.
[12:20pm] ctalbert: Ok.  Thanks bienvenu_ From the earlier comments, I thought there was something that would have be modified in Tbird.  Maybe I misread.
[12:20pm] bienvenu_: I'm not sure which approach that comment referred to...
[12:20pm] Fallen: bienvenu_: What do you think about comment #30 ? Sven suggests its about preventing the biff
[12:21pm] Fallen: the problem is that calendar is shown initially, but the biff selects the inbox, which switches back to mail view
[12:23pm] bienvenu_: Fallen - that's not exactly biff, but rather check for new messages on startup...
[12:23pm] Fallen: Yes, thats what I meant.
[12:24pm] bienvenu_: but yes, I understand what you mean...
[12:25pm] bienvenu_: I'm a little unclear how that forces things back to the mail view - does Lightning do that somehow?
[12:25pm] bienvenu_: or is there some side effect of selecting a folder that switches back to the mail folder pane?
[12:27pm] Fallen: Let me take a look how it works exactly. I believe selecting a folder is somehow observed and the view switches back. This is definitely ltn specific
[12:28pm] bienvenu_: so in ttheory if you had your own command line handler, you could supress the behavior for the startup folder, in the -calendar case?
[12:31pm] Fallen: bienvenu_: sorry, was disconnected. SelectFolder and SelectMessage are overridden. http://lxr.mozilla.org/mozilla/source/calendar/lightning/content/messenger-overlay-sidebar.js#580
[12:34pm] MarcoZ joined the chat room.
[12:34pm] MarcoZ: Fallen: *ping*?
[12:35pm] Fallen: busy, whats up?
[12:36pm] MarcoZ: Fallen, a question regarding the gdataprovider extension. I'm always getting a 404 error when trying to update an appointment or create a new one from Lightning. Reading events is OK, though. But if you're busy, we can talk some other time.
[12:37pm] Fallen: I'll look into it later, maybe they changed something.
[12:41pm] MarcoZ: Does anybody know if there's a way to switch the tabs (Mail, Calendar, Tasks) via the keyboard?
[12:41pm] davida left the chat room. (Quit: davida)
[12:49pm] bienvenu_: Fallen - so I think you could supress that behavior on startup just in the Lightning code, with your own command line handler
[12:49pm] ctalbert: MarcoZ: If there isn't a way, then that should be a bug.
[12:49pm] • ctalbert doesn't see one, but I'm using an old build atm
[12:50pm] Ramosa joined the chat room.
[12:50pm] Fallen: Ctrl 1, 3 and maybe 4
[12:51pm] Fallen: not sure if task mode got a key
[12:51pm] Wolf left the chat room. (Ping timeout)
[12:52pm] Fallen: bienvenu_: I guess that could work. I wonder why the others didn't come up with that...
[12:52pm] ctalbert: yeah ctrl 1 -> mail
[12:52pm] ctalbert: ctrl 3 -> calendar
[12:53pm] Fallen: ctalbert: any other implications? Do you think bienvenu's suggestion will work as expected?
[12:53pm] ctalbert: Fallen: None that I know of.  That sounds like a good solution. 
[12:53pm] Mc left the chat room. (Quit: ChatZilla 0.9.79 [Firefox 3.0b1/2007110904])
[12:54pm] ctalbert: We just need to make sure that -calendar gets to us in our code, and then take it from there.
(In reply to comment #32)
> [12:52pm] Fallen: bienvenu_: I guess that could work. I wonder why the others
> didn't come up with that...

Mhh, I can't tell... Maybe this is, because this function has not been overridden on the time of this bug reporting (one year ago).


> [12:53pm] Fallen: ctalbert: any other implications? Do you think bienvenu's
> suggestion will work as expected?
> [12:53pm] ctalbert: Fallen: None that I know of.  That sounds like a good
> solution. 

Well, I did not investigate further, but started some tests. For some reason these functions seem to be called only on startup and by the notification for new mails. I tested with Lighting 0.5 to override these and simply do nothing, when in calendar mode - which worked and I was still able to select the folder by clicking the folder in the folder pane.

Of course, this has to be changed for current Lightning versions, where the mail/calendar modes were introduced. To override these functions was explicitly wanted in bug 386636 - so we would need an extra decision for calendar mode on startup:
1. Simply ignore only the first SelectFolder()
2. Igrore every SelectFolder() and only override SelectMessage()
3. Ignore SelectFolder() and SelectMessage(), when started with '-calendar' until the user switches the manually to mail mode once


> [12:54pm] ctalbert: We just need to make sure that -calendar gets to us in our
> code, and then take it from there.

I also had problems with this in the past... I would appreciate any help in controlling the message window through an CommandLineHandle, because it does not exist this early. Or do I have to open the window myself and use 'PreventDefault'?
(In reply to comment #33)
> I also had problems with this in the past... I would appreciate any help in
> controlling the message window through an CommandLineHandle, because it does
> not exist this early. Or do I have to open the window myself and use
> 'PreventDefault'?
You don't need to control the message window, neither is it something you need to care about. All you need to do is to remember that Lightning has been instructed to automatically switch to the calendar mode upon startup and invoke the necessary bits and pieces during the load handler (ltnOnLoad).
If possible I'd go for option (1), because we can't assume that SelectFolder is generally not called at startup. Option (3) wont work, because SelectMessage is called from the email slider and that shouldn't be ignored just because the program was called with -calendar.
Flags: wanted-calendar0.8+
I have a semi-working solution for this bug, but it probably won't make 0.8
Philipp, thanks for investigating.
I delayed work on this, until I accept the new design... (I never used Ltn0.7!)
But IMHO version 0.8 is more complete and I will accept the new modes. I just wanted to wait for the release of 0.8 to go on.

If you have something to solve this, feel free to post it here.

(In reply to comment #36)
> I have a semi-working solution for this bug, but it probably won't make 0.8

According to comment #25 this would be no problem ;-)
Summary: No option to start Thunderbird with Lighting-View (i.e. month view) upon start-up → No option to start Thunderbird with Lightning-View (i.e. month view) upon start-up
Not going to happen for 0.8.
Flags: wanted-calendar0.8+ → wanted-calendar0.8-
Summary: No option to start Thunderbird with Lightning-View (i.e. month view) upon start-up → No command line switch to start Thunderbird with calendar view upon start-up
Flags: wanted-calendar0.8- → wanted-calendar0.9+
(In reply to comment #34)
> You don't need to control the message window, neither is it something you need
> to care about. All you need to do is to remember that Lightning has been
> instructed to automatically switch to the calendar mode upon startup and invoke
> the necessary bits and pieces during the load handler (ltnOnLoad).

I'm at the same problem I was some months ago:
   How do I _REMEMBER_ the command-line switch?

Maybe I'm blind - but I can only handle command-line switches in a script in 'components', right? The switches are not available through 'window.arguments' in any Lightning script...
When I install a command-line handler, how could this access some global variables without installing a component service that could be 'asked' later - do we have to go this way for this simple demand???

(In reply to comment #36)
> I have a semi-working solution for this bug, but it probably won't make 0.8

It would be great, if you could post this as a WIP patch - maybe things are easier for me then ;-)

I created a working solution now, using another existing interface (nsISupportsString) on the commandline-handler to get the desired mode.

This is working fine for me, but there are still some questions:
- Should we better create an own interface with IDL to store and retrieve the desired mode?
- Depending on the current design of Lightning there are much more options, that could be implemented, e.g. to show Task mode on startup...

I implemented the following:
'thunderbird.exe -calendar'
'thunderbird.exe -calendar month'
'thunderbird.exe -calendar week'
'thunderbird.exe -calendar multiweek'
'thunderbird.exe -calendar day'

Whenever a non-existent view (or none) is requested, the last visited will be shown. Depending on the possibilities, there would be another way to go: we could implement 'real' commands for Lighting, e.g.:
'thunderbird.exe -calendar show=month'
'thunderbird.exe -calendar newtask'
'thunderbird.exe -calendar import=mycal.ics'
'thunderbird.exe -calendar export=Birthdays,C:\birthday.ics'

What do you think? Maybe this could go into another bug, if requested by others...
Attachment #277678 - Attachment is obsolete: true
Attachment #314785 - Flags: review?(ctalbert)
I already found a small issue with this patch:

- start TB with '-calendar'
- switch to mail mode manually

Actual Result:
- no folder is selected and application title does not change

Expected Result:
- Inbox or 'overview page' of main account should be selected and app title should change to "Inbox - Thunderbird" or something else

Any ideas how to handle this???
Attached patch Philipp's WiP (obsolete) — Splinter Review
This is the semi-working solution I was talking about. It keeps the command line handler out of chrome and also works for sunbird. Its probably bitrotten though.

Sven, feel free to use (parts, all, whatever) of this code if you decide to create a new patch. I was waiting with this, since I first wanted to fix bug 426746, which already creates some files used here.

Hope it helps, sorry for doing possibly duplicate work, at the time I wrote that, it wasn't clear to me you were actively working on this bug.
Once again, I find myself in a position of not knowing what to do with this bug.  Looking briefly at the two different approaches, I tend toward Sven's approach because it is simpler and less wide-ranging than Philipp's.

Philipp, how much of that patch was refactoring startup code and how much of it was fixing this to work with sunbird?

Clint, some of the work done in that patch has already been done in a previous bug, we already have a calendar-chrome-startup.js now, therefore some chunks are obsolete. I just attached my patch since it may provide some ideas for consolidating the two command line handlers.

I'd like to see a solution that doesn't just also implement the command line handler for lightning, but cleans up the code and creates a common command line handler, so that adding futher options doesn't require code changes in two locations. Also this would clean up the resources/ directory a bit more.

I like the idea of an idl interface for our command line handler to allow retrieving passed options via a component. This would easily allow adding more options.

If I would be doing the review, I'd probably r- the patch to consolidate the command line handlers (sorry ;-).
Comment on attachment 314785 [details] [diff] [review]
Re-designed patch with CLH to work with Lightning 0.8+

(In reply to comment #44)
> If I would be doing the review, I'd probably r- the patch to consolidate the
> command line handlers (sorry ;-).
> 

Philipp, I totally agree, at least since bug 415906 requests for an option to show a specific date on startup for lightning, which makes sense for me, too.

Maybe the option "-calendar" is totally useless then?!

Unfortunately this starts to go beyond my capabilities... I have not started to look at 'calendar-chrome-startup.js', nor do I understand the command-line handling in Sunbird.

Philipp, do you feel able to take this bug?
Otherwise I'm not sure whether I can get this working before 0.9 release :-(
Attachment #314785 - Flags: review?(ctalbert)
(In reply to comment #45)
> (From update of attachment 314785 [details] [diff] [review])
> (In reply to comment #44)
> > If I would be doing the review, I'd probably r- the patch to consolidate the
> > command line handlers (sorry ;-).
> > 
Ok sounds good.  Sven, I'm really sorry about letting that patch sit in my review queue for so long.  It somehow slipped my notice.  I won't let that happen again.
I'll see what I can do. I have quite a few larger patches on my plate so I'm not sure when I'll get to this. Just write me an email if you find time before I've uploaded a patch so I can tell you if I've already started taking a closer look or not.
Assignee: giermann → philipp
Status: ASSIGNED → NEW
Attached patch Commandline options WiP - v6 (obsolete) — Splinter Review
This patch mostly works, there is one open issue I've discovered:

* Something is fishy with the menus, starting with -taskmode or -calendar gives
  a mix of both mail and calendar menus, works when switching back and forth
  modes

* Something is keeping -calendar from working. I'm too tired to debug this now
  but I think its a minor issue

* In case this gets ready before 0.9, there are still hardcoded strings that
  need to be localized after the release.


Also, we should think about what we want those switches to be called. Keep in mind they should be as sensible as possible for both sb and ltn. Right now I have


-calendar <view>         Start calendar in <view>, where the <view> is optional
-taskmode                Start lightning in task mode
-showdate <date>         Show a specific date, parsed using jsdate
-url <type>,<url>        Add a calendar of a specific type. When type, is
                         omitted it defaults to ICS.

I'm open to name changes and such. I could well imagine using:

-mode <mode>     (i.e -mode calendar or -mode task)
-view <view>     (i.e -view week or -view month)

instead.
Attachment #314785 - Attachment is obsolete: true
Attachment #314829 - Attachment is obsolete: true
I'd reserve "calendar" for showing one particular calendar and disabeling the rest in the future, let's use "view". I know quite some people would like this. 
It'd probably be worth to prefix calendar commandline options with e.g. cal or use less generic names, so there aren't any name clashes with e.g. -url.
How about: 
-calview <view>
-calmode <mode>
-calimport <type>,<url>
I was using -url since osx LaunchServices uses this switch to start up ICS files, but it will have the same problem as noted in one of the TODO comments:

Regardless of windows,linux,mac, how do we know if the url passed (either without a switch or with -url) is one that calendar can read? The way the commandline interfaces work we need to do this synchronously, which means we can't just open the URL and find out.

In an ideal world, if the url is one that calendar can read, then i.e the .ics file that was doubleclicked on should be subscribed to, otherwise it can be left to thunderbird to decide how to open it.
Blocks: 415906
(In reply to comment #48)
> * Something is fishy with the menus, starting with -taskmode or -calendar gives
>   a mix of both mail and calendar menus, works when switching back and forth
>   modes
I solved this by an initial call to swapPopupMenus() in ltnInitializeMenus().

> * Something is keeping -calendar from working. I'm too tired to debug this now
>   but I think its a minor issue
This seems to be related to WHEN commonInitCalendar() is called. I shifted it down in ltnOnLoad() which works for me now and also prevents its call twice, as it's positioned after the removal of the onLoad listener.

There was also a minor case-typo in calHandleChromeStartupOptions():
-    if (showDate && showdate.length) {
+    if (showDate && showDate.length) {

Futhermore I completed your addition of return values, also to selectCalendarView() and ltnSelectCalendarView().

I did not change any names of the command-line switches, which is rather quickly done.

There are still some possibilities to consolidate some code:

- The check for existence of requested views and the current mode could be removed from ltnShowCalendarView() as this is already done in switchToView() and ltnSwitch2Calendar():
>function ltnShowCalendarView(type) {
>    if (ltnSelectCalendarView(type)) {
>	ltnSwitch2Calendar();
>	return true;
>    }
>    return false;
>}

- change ltnSwitch2Calendar() to also call ltnSelectCalendarView() or switchToView() instead of showCalendarView()

- take care of and hand over the result code from switchToView() also in ltnSwitch2Calendar()

I did not change these mainly because of the existing comment for showCalendarView():
  * XXX Kind of confusing. This function calls the app specific function, which
  * again calls the common switchToView function. They should be consolidated in
  * a different bug.
Attachment #332310 - Attachment is obsolete: true
Attachment #338838 - Flags: review?(philipp)
Sven, thanks for the patch. I'll be taking a look at this after the 0.9 release, since the change is a bit too risky for now.
Target Milestone: --- → 1.0
Blocks: 423374
One more issue to resolve:

When starting with '-calendar' and then opening one mail folder in another window (right-click / Open), the calendar mode it displayed in this new window again.

This should be fixed by resetting the mode preference after ONE window has been opened.
Status: NEW → ASSIGNED
would be good if the same kind of switch can be implemented for OS X!
Thanks guys, love your work, no where's a donation button?

-jed.
I would like to donate, too!
I look forward to see this functionality implemented!
Again, is there anyone who is willing to provide me with a compiled version of lightning with this patch? (I use linux) Or, can you please indicate me where I can find a configuration file for linux (Ubuntu Hardy) in order to compile it by myself?
I can test it, even if I am not a programmer
thank you
Alberto
Flags: wanted-calendar0.9+
(In reply to comment #56)
> Again, is there anyone who is willing to provide me with a compiled version of
> lightning with this patch? (I use linux)
> I can test it, even if I am not a programmer

Since I did not get any response from Alberto by mail, I tried to attach the patched version for Linux here (but it's too large) - I did only test it on Windows, but did the same modifications in Linux version.
Note: There's an dummy update URL to avoid automatic back-rev to 0.9!

If anyone is interested, feel free to contact me.
Thank you Sven
sorry your first email was labeled as spam by gmail :(

I am starting to play with it
The first thing I wanted to do is integration with Gnome Clock Applet
Here is the trick I came up with today:

1) create the following script and name it "evolution"
 
---------------------------------

#!/bin/bash
d=`echo $1 | grep "calendar:///?startdate="`
if [ "$d" != "" ]; then
	yyyy=${d:23:4}
	mm=${d:27:2}
	dd=${d:29:2}
	thunderbird -calendar day -showdate `echo "$yyyy/$mm/$dd"` &
	exit 0
fi

d=`echo $1 | grep "task:"``echo $1 | grep "component=tasks"`
if [ "$d" != "" ]; then
	thunderbird -taskmode &
	exit 0
fi

d=`echo $1 | grep "component=calendar"` 
if [ "$d" != "" ]; then
	thunderbird -calendar &
	exit 0
else
	evolution2 $1 $2
fi

----------------------------------------

2) rename /usr/bin/evolution to /usr/bin/evolution2
3) copy the script "evolution" to /usr/bin and make it executable
4) Try to double-click on a date on Gnome Clock Applet (or to click on a button) and see what it happens

Sven, 
the only thing that is missing is putting the existing thunderbird window in foreground every time you call it from command line. Is it a difficult thing to implement?
Sorry, one (fundamental) part of the trick was missing :)

You must first install apache on your local machine and enable dav support
then you create a local "web" calendar with lightning and you enable it also in evolution, so that Gnome Clock Applet show the same events and tasks of lightning (otherwise the trick does not make much sense)

If someone wants the details, I can give him/her
(In reply to comment #58)
> the only thing that is missing is putting the existing thunderbird window in
> foreground every time you call it from command line. Is it a difficult thing to
> implement?

This seems to be a Linux-only issue - it is working perfect on Windows; except for one thing:

@Phillipp: STR

1. Start TB without commandline option
2. "thunderbird.exe -calendar"
   EXPECTED: Display Calendar in existing window
   ACTUAL:   Display Calendar in existing window
3. "thunderbird.exe -mail"
   EXPECTED: Display Mail mode in existing window
   ACTUAL:   Window is brought to foreground, but still with Calendar

It should also be discussed what should happen, if TB is started again without any option: Mail mode or just foreground?
Sven,
another bug: printing emails does not work any more when I install your patched version, while with the official version of lightning it works
Maybe another linux-related issue?

Moreover, even if I close thunderbird, the task appears to be still running (with ps -A, you still see thunderbird-bin and run-mozilla.sh).
(I had to manually kill the task to manage to reinstall the official version of lightning to test the printing issue)
Well, I uninstalled the official version, I reinstalled the patched version again, and now all the bugs I signalled above (included tbd window not in foreground) disappeared!
sorry...
the tbd window in foreground works only sometimes...
Has anyone planned how the open via command line features incorporates into the new tabbed model used in Thunderbird 3.0b1pre / Lightning 1.0pre?
I just had a first look at the new layout - it seems to be very unfinished yet; not only regarding Lightning.

I would suggest to give the same experience via commandline, as it is with the mode switching buttons!

But it does indeed open further possibilities:
What to do if someone issues TB with commandline "-mail -calendar -task" ?

I would assume he wants 1 window (or tab) for each mode: Mail, Calendar AND Task.

BTW: The tabbed window gives good abilities to introduce Task mode in Sunbird ;-)
Sven,
I tested your patch for a while on ubuntu 8.04 and I can say that the only bug/problem is that the tbd window only sometimes is put in foreground when called from command line.
I tried to find a rule, but there isn't one: sometimes, when all other windows are not maximized, the tbd window is put in foreground, but sometimes is not...
When some other windows are maximized, generally the tbd window stays in background even when called.
Maybe a different function must be called in linux, to put the window in foreground? (I'm not a programmer so I'm guessing :) )
Are there any plans to include an "-import" command-line switch?

It was mentioned in comment #40 and #50 but I did not spot that function in the proposed patch (I am not a coder, so I might be wrong).
Debitrotting this patch doesn't seem quite enough. I've done so locally but haven't succeeded in opening tabs yet. Also I do hope there is a better solution than using prefs. It does seem that using prefs is a common option, but looking at the code I'm not quite happy yet.

I think we should keep the number of options to a minimum in this patch and then add options like -import in a subsequent patch/bug.
Comment on attachment 338838 [details] [diff] [review]
Commandline options v6 working

Removing review request because this patch is significantly bitrotted.
Attachment #338838 - Flags: review?(philipp)
Blocks: 494630
Target Milestone: 1.0 → ---
No longer blocks: 423374
Any update on this?
I'm interested to. Any update?
Me too...
I'm also interested...
tl;dr: Please make this happen, will ya?

Even after getting the boot from Mozilla, the Thunderbird team has been doing great work recently. But how on earth are people expected to work with calendar on a daily basis and go through the "find the icon and click on" routine each and every time?

Even if there's some new magic way to get right to Lightning I'm not aware of (I'm running 44b), please add the legacy -calendar shortcut because this is such a widespread (defunct) solution.
Now that there is an extension [1] for Gnome Shell to Lightning calender of Thunderbird, it would be nice if one could open TB diretly with calendar view... All we need is a startup switch and a new thunderbird.desktop file to include also MimeType "text/calendar" so that TB can be chosen as default app for calendar, too.

[1] https://addons.mozilla.org/en-US/thunderbird/addon/eds-calendar-integration/

Another 2 years in us simple folk are wondering: Who is this 13 year old bug assigned to anyway? This is so sad since tb is doing great recently.

Please give us the option to start tb in calendar mode, this is a major nuissance in daily productivity. A lot of times I simply want to check or add an calendar event - and not click through email mode or see that my account whatever has n new messages.

Pretty please with sugar on it :-) ?

Component: Lightning Only → General

Opening thunderbird with -calendar would be very useful. Any progress on that? Something is blocking ?

Maybe you want to provide a patch?
For addressbook it registers itself here: https://searchfox.org/comm-central/rev/e80a66e5cdd9fe3915b7979cbf3d7467bcb70cfa/mailnews/addrbook/modules/components.conf#17 then handles it here: https://searchfox.org/comm-central/rev/e80a66e5cdd9fe3915b7979cbf3d7467bcb70cfa/mailnews/addrbook/modules/AddrBookManager.jsm#526-539
I don't know if calendar has a suitable module to piggyback on, or if creating a new module is better.

Assignee: philipp → nobody
Status: ASSIGNED → NEW

Sure, i will look into this

Blocks: 1739835
Assignee: nobody → rob
Status: NEW → ASSIGNED
Target Milestone: --- → 104 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/a3d1f3791ae8
Add -calendar commandline switch. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED

Verified working on Thunderbird Daily 104.0a1 - 20220722094822 (linux64).

Tested starting Thunderbird with -calendar argument when no other instance is running; verified that the Calendar tab is loaded and in focus on startup.

Tested running "thunderbird -calendar" when an instance is already running (with no calendar tab). Verified that the running instance opens a calendar tab and switches focus to it.

Tested running "thunderbird -calendar" when an instance is already running with a calendar tab open, but the mail tab active. Verified that the focus switches to the existing calendar tab.

Status: RESOLVED → VERIFIED

Verified same on Windows (x64).

Comment on attachment 9286523 [details]
Bug 359807 - Add -calendar commandline switch. r=#thunderbird-reviewers

[Approval Request Comment]
Regression caused by (bug #): N/A
User impact if declined: it's just a long-requested feature
Testing completed (on c-c, etc.): Verified on 104 Daily linux64 and win64
Risk to taking this patch (and alternatives if risky): Low risk. Just adds a function to open a calendar window and hooks it into the nsICommandLineHandler implementation. The code itself was copied from the implementation for -addressbook.

Attachment #9286523 - Flags: approval-comm-esr102?

Comment on attachment 9286523 [details]
Bug 359807 - Add -calendar commandline switch. r=#thunderbird-reviewers

[Triage Comment]
Approved for esr102

Attachment #9286523 - Flags: approval-comm-esr102? → approval-comm-esr102+

I've just tested this after upgrading to 102.3.1. Running "thunderbird -calendar" on the command line when an instance of thunderbird is already running loads the calendar, but in the existing window, rather than a new window as I requested in bug 1763083 (which got marked as a duplicate of this one). Is there any way to open the calendar in a new window from the commands line?

(In reply to Alistair Cunningham from comment #91)
There are more command-line options in Firefox and Seamonkey which probably also work in Thunderbird:
https://udn.realityripple.com/docs/Mozilla/Command_Line_Options
Did you try the -new-window?

"thunderbird -calendar -new-window" also loads the calendar in the existing window, not in a new window. "thunderbird -h" makes no mention of the -new-window option.

You need to log in before you can comment on or make changes to this bug.