Search code examples
thunderbirdlightning

How to get todos from Thunderbird/Lightning calendars?


I can't find how to get all the todos of a calendar in Lightning. I thought the functions getItem() and getItems() from the calICalendar Interface (here) were the solution but I could not make it work properly.


Solution

  • You are going in the right direction. You just need to pass the flag that you want todos only. An example can be found here.

    To elaborate more on your example below, there are a few syntax errors and you might need different flags. I'm not sure why the alert is needed, that sounds to me like the event loop is not being spun. In what context are you calling these bits?

    Try this:

    var arrayItems = new Array();
    
    var todoListener = {
        onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {},
        onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {  
            arrayItems = arrayItems.concat(aItems);
        }
    };
    
    var filter = aCalendar.ITEM_FILTER_TYPE_TODO | aCalendar.ITEM_FILTER_COMPLETED_ALL;
    aCalendar.getItems(filter, 0, null, null, todoListener);